I'm trying to get a Multipart POST to work with fastify-multipart, but whenever I post a multipart file to the endpoint my service crashes with the following error:
req.raw[kMultipart] = true
^
TypeError: Cannot set property 'Symbol(multipart)' of undefined
at Parser.setMultipart [as fn] (/service/node_modules/fastify-multipart/index.js:24:23)
at ContentTypeParser.run (/service/node_modules/fastify/lib/contentTypeParser.js:103:27)
at handleRequest (/service/node_modules/fastify/lib/handleRequest.js:35:39)
at onRunMiddlewares (/service/node_modules/fastify/lib/middleware.js:22:5)
at Holder.done (/service/node_modules/middie/middie.js:90:9)
at xXssProtection (/service/node_modules/x-xss-protection/dist/index.js:47:13)
at Holder.done (/service/node_modules/middie/middie.js:112:11)
at nosniff (/service/node_modules/dont-sniff-mimetype/dist/index.js:5:9)
at Holder.done (/service/node_modules/middie/middie.js:112:11)
at xDownloadOptionsMiddleware (/service/node_modules/ienoopen/index.js:5:5)
Am I missing a dependency or something like this?
"fastify": "^2.0.0",
"fastify-multipart": "^4.0.6",
In index.js this is the code:
const kMultipart = Symbol('multipart')
function setMultipart (req, payload, done) {
// nothing to do, it will be done by the Request.multipart object
req.raw[kMultipart] = true
done()
}
req.raw seems to be undefined.