fastify-raw-body icon indicating copy to clipboard operation
fastify-raw-body copied to clipboard

Support for blob/non-json requests

Open chriskuech opened this issue 1 year ago • 2 comments

From what I can tell, this module allows you to access the raw body of the request as a Buffer, but there is no way to disable still parsing it as JSON. I would like to use this to access the raw binary of the request, which would require--

  • not parsing the body as JSON
  • associating * content type (excluding application/json) with the raw body parser

chriskuech avatar Oct 01 '24 19:10 chriskuech

I actually got this working without the library:

  app.addContentTypeParser('*', { parseAs: 'buffer' }, (req, body, done) => {
    return Buffer.isBuffer(body)
      ? done(null, body)
      : done(new Error('Invalid body'))
  })

chriskuech avatar Oct 01 '24 20:10 chriskuech

Reopening as it seems a good use case

Eomm avatar Mar 01 '25 07:03 Eomm