0
votes

I am uploading files from front end (Angular) using multipart/form-data to S3 via AWS Lambda. I have installed the serverless-apigw-binary plugin and in my serverless.yml have included the configuration as mentioned in this plugin's documentation. On my API gateway I can see that the plugin adds the binary media types values mentioned in the serverless.yml file

However when I view the file on S3 it is corrupted. Does not matter what type of file I upload (image, doc, pdf) I cannot open it on download. This issue is also present when I make a direct POST request to my lambda function from Postman.

Am I missing any step? What is the correct way to accept binary files in Lambda?

2

2 Answers

0
votes

You’ll need to configure binary media types in AWS for API Gateway to be able to handle multipart/form and that kind of stuff.

0
votes

Try this.

Just change aws-serverless-express to aws-serverless-express-binary.

$ yarn add aws-serverless-express-binary

https://www.npmjs.com/package/aws-serverless-express-binary