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
Our busboy implementation will give the feedback that the file is to big and cut off the file stream. Thats why your big file is smaller. What is missing is Handling the feedback and error with file too big.
addToBody is not documented in the README anymore and I believe is deprecated. If you use attachFieldsToBody: true instead, it does throw when the limit is exceeded
Other than that, I think removing these undocumented options is the best way forward
Prerequisites
Fastify version
4.15.0
Plugin version
7.6.0
Node.js version
16.13
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.3.1
Description
When using
@fastify/multipart
empty files are returned when the file size limit is exceeded (default: 1mb).If I send files larger than the limit to the API and access them body, I receive empty files when the file size exceeds the limit.
e.g:
File with 1.1mb
{ data: undefined, filename: 'DJI_0366.JPG', encoding: '7bit', mimetype: 'image/jpeg', limit: true }
If the file is smaller then the limit everything works correctly and the data field is defined.
File with 0.8mb:
{ data: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff e2 02 28 49 43 43 5f 50 52 4f 46 49 4c 45 00 01 01 00 00 02 18 00 00 00 00 04 30 00 00 ... 212574 more bytes>, filename: 'DJI_0365.JPG', encoding: '7bit', mimetype: 'image/jpeg', limit: false }
Reason
Steps to Reproduce
Register module with the
addToBody
Optionapp.register(fastifyMultipart, { addToBody: true });
And access the files e.g. using nestjs
@Post() post(@Body() body: { files: Buffer[] }): void { return this.appService.createFiles(body.files); }
Expected Behavior
Either ban this option or return a 413 error message if the file exceeds the size limit.
This is a serious issue that can result in data loss
The text was updated successfully, but these errors were encountered: