You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.1.0
Plugin version
7.1.0
Node.js version
v16.14.2
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.3
Description
In my case, when I apply { attachFieldsToBody: 'keyValues' }, the uploaded image was been stringified from buffer with buffer.toString() which is default to uft-8 encoding. And it might not able to be converted correctly back to the buffer.
Maybe buffer.toString('binary') or buffer.toString('base64') is more general and acceptable encoding.
If there is no other concern I could make a PR for it.
Steps to Reproduce
importfastifyMultipartfrom'@fastify/multipart'import{writeFile}from'fs/promises'app.register(fastifyMultipart,{attachFieldsToBody: 'keyValues'})app.post('upload',async(req,reply)=>{constbuffer=Buffer.from(req.image)awaitwriteFile('path',buffer)// which is not a valid imagereply.send()})
Expected Behavior
The written image should be read correctly.
The text was updated successfully, but these errors were encountered:
Prerequisites
Fastify version
4.1.0
Plugin version
7.1.0
Node.js version
v16.14.2
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.3
Description
In my case, when I apply
{ attachFieldsToBody: 'keyValues' }
, the uploaded image was been stringified from buffer withbuffer.toString()
which is default to uft-8 encoding. And it might not able to be converted correctly back to the buffer.fastify-multipart/index.js
Line 157 in 80d9509
Maybe
buffer.toString('binary')
orbuffer.toString('base64')
is more general and acceptable encoding.If there is no other concern I could make a PR for it.
Steps to Reproduce
Expected Behavior
The written image should be read correctly.
The text was updated successfully, but these errors were encountered: