Open jacobg opened 1 year ago
I believe this would solve #1144 for people trying to use multer on cloud functions.
@LinusU @inigomarquinez this is blocking us and a lot of other people. Is this something you would be happy to support in Multer? 🤔
There are even unmaintained forks of multer just to fix it for Cloud Functions: https://www.npmjs.com/package/multer-functions
I guess this is something for @expressjs/triagers to decide! 😀
Multer calls
req.pipe(busboy)
to stream in the request body for processing: https://github.com/expressjs/multer/blob/07c9e84477e19f6f5016330b0c37c7cfbf085b8d/lib/make-middleware.js#L177However, on Google Cloud Functions (GCF), it wraps Express to pre-stream the entire request body into a custom
res.rawBody
property. This causes Multer to break on that runtime. Here is some background discussion: https://stackoverflow.com/a/47319614/1237919It would be a very simple solution to instead call the following when running on GCF:
This could be supported by either: 1) adding a configuration parameter specifically for GCF. 2) adding a configuration parameter function to override the reading in of data however the caller wants.
I would be happy to submit a pull request for this. Would you be willing to accept it? Do you prefer one of these 2 options?
Thanks.