Why is file being corrupted during multipart upload into express running in aws lambda? Why is file being corrupted during multipart upload into express running in aws lambda? express express

Why is file being corrupted during multipart upload into express running in aws lambda?


Potential answers:

Found this https://forums.aws.amazon.com/thread.jspa?threadID=252327

API Gateway does not natively support multipart form data. It is possible to configure binary passthrough to then handle this multipart data in your integration (your backend integration or Lambda function).

It seems that you may need another approach if you are using API Gateway events in AWS to trigger the lambda that hosts your express server.

Or, you could configure API Gateway to work with binary payloads per https://stackoverflow.com/a/41770688/304832

Or, upload directly from your client to a signed s3 url (or a public one) and use that to trigger another lambda event.

Until we get a chance to try out different API Gateway settings, we found a temporary workaround: using FileReader to convert the file to a base64 text string, then submit that. The upload does not seem to have any issues as long as the payload is text.