Trying to use google cloud functions, which requires functions to be exported, without access to the app class (like so)...
exports.helloWorld = (req, res)=>{
}
I'm wondering how to initialize multer within a function like above, since multer is traditionally implemented in the argument class like below...
app.post('/', multer().single(...), function (req, res) {
})
Anyone have any ideas? Sorry if the question is confusing/vague, and feel free to ask me to clarify anything
const parseBody = multer().single(...)
exports.helloWorld = (req, res, next) => {
parseBody(req, res, function (err) {
if (err) return next(err)
// use `req.file` here
})
}
@LinusU Unfortunately, calling it that way produces a TypeError: Cannot read property 'transfer-encoding' of undefined error.
Similar to issue #167 where it's caused by calling multer incorrectly
hehe, sorry, I had a typo :)
I've edited the post
Ah, it's working now. Thanks!
Most helpful comment