Serverless API gateway transforming request into base64 : <p>I have a serverless app which uploads files to s3 (via POST request) and serves them (via GET request)</p>

<p>I am using <code>serverless-apigw-binary</code> and <code>serverless-apigwy-binary</code> plugins to allow me to return binary data in the form of an image. In order to allow the URL to work with browsers, I have to set the binary types to <code>*/*</code>. </p>

<p>In order to upload an image the POST endpoint takes a body like { "base64": "..." }. However with this configuration the entire body is coming through as a base64 encoded string. How can I prevent the request body with <code>application/json</code> being transformed?</p>

<p>See <code>serverless.yml</code> below:</p>

<pre><code>service: image-service

custom:
  envName: ${opt:stage, self:provider.stage}
  domains:
    prod: api.&lt;mydomain&gt;
    dev: dev-api.&lt;mydomain&gt;
  customDomain:
    basePath: images
    domainName: ${self:custom.domains.${self:custom.envName}}
    certificateName: "*.&lt;mydomain&gt;"
  apigwBinary:
    types:
      - '*/*'

provider:
  name: aws
  runtime: nodejs8.10
  region: eu-west-1
  memorySize: 1536

  role: ImageRenderingRole

  environment:
    ENV_NAME: ${self:custom.envName}
    APP_NAME: image-service
    BUCKET: &lt;mybucket&gt;

plugins:
  - serverless-offline
  - serverless-domain-manager
  - serverless-apigw-binary
  - serverless-apigwy-binary

functions:
 uploadImage:
   handler: handler.uploadImage
   events:
     - http:
      path: /
      method: POST

  getImage:
    handler: handler.getImage
    events:
      - http:
          path: 'images/{idAndFormat}'
          method: get
          contentHandling: CONVERT_TO_BINARY
          parameters:
              paths:
                idAndFormat: true
</code></pre>
