multer
multer copied to clipboard
Add configuration parameter to support Google Cloud Functions
Multer calls req.pipe(busboy)
to stream in the request body for processing:
https://github.com/expressjs/multer/blob/07c9e84477e19f6f5016330b0c37c7cfbf085b8d/lib/make-middleware.js#L177
However, 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/1237919
It would be a very simple solution to instead call the following when running on GCF:
busboy.end(req.rawBody)
This could be supported by either:
- adding a configuration parameter specifically for GCF.
- 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.
I believe this would solve #1144 for people trying to use multer on cloud functions.