title: AWS Lambda - PDF Uploads to S3 return blank pages
body: <p>I'm looking to upload a PDF statement that contains some pages of data however the PDF uploaded to S3 has been returning blank pages. It seems most of the solutions seem to revolve around converting the <code>Buffer</code> type to base64, I've tried that and I'd get a blank PDF.</p>
  <p>I've manually added the binary media type on API Gateway <code>multipart/form-data</code> and it still results in a blank pdf.</p>
  <p>How can I ensure the pdf is not a blank?</p>
  <pre class="lang-js prettyprint-override"><code>import { Handler, Context, Callback } from &quot;aws-lambda&quot;;
  import S3, { PutObjectRequest } from &quot;aws-sdk/clients/s3&quot;;
  
  import httpMultipartBodyParser from &quot;@middy/http-multipart-body-parser&quot;;
  import httpErrorHandler from &quot;@middy/http-error-handler&quot;;
  import cors from &quot;@middy/http-cors&quot;;
  import middy from &quot;@middy/core&quot;;
  import createError from &quot;http-errors&quot;;
  
  const s3 = new S3();
  
  const anonymizer: Handler = async (
    event: any,
    _context: Context,
    callback: Callback
  ) =&gt; {
    const {
      emailAddress,
      pdf: { filename, mimetype, content },
    } = event.body;
  
    const uploadRequest: PutObjectRequest = {
      Bucket: `anon-${process.env[&quot;NODE_ENV&quot;]}`,
      Key: `${emailAddress}/${filename}`,
      ContentType: mimetype,
      Body: content,
    };
  
    try {
      const { Location } = await s3.upload(uploadRequest).promise();
      callback(null, {
        statusCode: 200,
        body: JSON.stringify({ fileLocation: Location }),
      });
    } catch (error) {
      throw createError(error.statusCode, error.errorMessage, error);
    }
  };
  
  export const anonymizerHandler = middy(anonymizer)
    .use(httpMultipartBodyParser())
    .use(httpErrorHandler())
    .use(cors());
  
  </code></pre>