fastify-multer icon indicating copy to clipboard operation
fastify-multer copied to clipboard

Fastify v5 fails with HTTP 415 FST_ERR_CTP_INVALID_MEDIA_TYPE

Open nioc opened this issue 1 year ago • 1 comments

When I upgrade from Fastify v4.28 to 5.2, uploads of multipart/form-data failed with a 415 HTTP:

{
  "code": "FST_ERR_CTP_INVALID_MEDIA_TYPE",
  "name": "FastifyError",
  "statusCode": 415,
  "message": "Unsupported Media Type: multipart/form-data; boundary=---------------------------33065737953259411260621758869"
}

I found a workaround by replacing the standard :

server.register(multer.contentParser)

with the following:

server.addContentTypeParser('multipart/form-data', function (request, payload, done) {
  done(null)
})

I suggest you change the code on lib/content-parser.ts with:

  fastify.addContentTypeParser('multipart/form-data', setMultipart)

nioc avatar Dec 29 '24 17:12 nioc

@fox1t Hope your upgrading

samchon avatar Jan 20 '25 12:01 samchon