multer icon indicating copy to clipboard operation
multer copied to clipboard

Binary file parsing on AWS lambda is broken

Open Craigfis opened this issue 4 years ago • 4 comments

Using multer to parse a multipart form containing image files results in incorrect file content (larger and corrupted content) when run within an AWS lambda behind an AWS API gateway proxy.

Craigfis avatar Sep 12 '19 23:09 Craigfis

@Craigfis - to prove of disprove this, can you provide a standalone test case?

gireeshpunathil avatar Sep 13 '19 01:09 gireeshpunathil

I am unable to provide a standalone test case as it only fails when run as an AWS lambda called through an API gateway proxy. Other people have been reporting the same problem: https://stackoverflow.com/questions/51683399/how-to-use-multer-s3-in-aws-lambda-handler-as-middleware https://stackoverflow.com/questions/50989630/why-is-file-being-corrupted-during-multipart-upload-into-express-running-in-aws https://github.com/expressjs/multer/issues/597

Others have created specific parsers for handling this scenario: https://github.com/myshenin/aws-lambda-multipart-parser https://develandoo.com/blog/parsing-multipart-body-aws-lambda-function-serverless/

I'm still not clear on what multer would need to do differently to handle this scenario.

Craigfis avatar Sep 13 '19 17:09 Craigfis

+1

bqrichards avatar Aug 13 '21 14:08 bqrichards

How are you running Express on Lambda?

I don't think that this is an error in Multer, since I'm pretty sure that I've been using Multer on Lambda deployed via scandium without issue...

LinusU avatar Aug 18 '21 17:08 LinusU