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.x.x
Plugin version
8.3.0
Node.js version
LTS
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Debian 12
Description
I have very different behavion on different files. Currently only tested with 2 image files, one is JPG ~2.3 Mb, another one is upscaled PNG ~22 Mb. Using following code:
const fastify = require('fastify')();
fastify.register(require('fastify-multipart'));
fastify.post('/upload', async function (req, res) {
let file = await req.file({ limits: { fileSize: 1024 * 1024 }, throwFileSizeLimit: true });
if (file.file.truncated) {
console.log('File too large');
res.send('File too large');
return res;
}
res.send('OK');
});
fastify.listen(3000, (err) => {
if (err) throw err;
console.log(`server listening on ${fastify.server.address().port}`);
});
Problem is, while uploading one file, file limit is working fine and when uploading another one, it isn't working at all. If i read it right, limits are in bytes, so, using (1024*1024) should be limited to 1 Mb. Here are two responses I get:
But, when you change the limit to only 1024, which would be 1Kb everything is working fine. So, what could be the problem?!
Here are files I'm uploading, so you can see the're have matching file size:
Link to code that reproduces the bug
No response
Expected Behavior
No response
The text was updated successfully, but these errors were encountered:
Prerequisites
Fastify version
4.x.x
Plugin version
8.3.0
Node.js version
LTS
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Debian 12
Description
I have very different behavion on different files. Currently only tested with 2 image files, one is JPG ~2.3 Mb, another one is upscaled PNG ~22 Mb. Using following code:
Problem is, while uploading one file, file limit is working fine and when uploading another one, it isn't working at all. If i read it right, limits are in bytes, so, using (1024*1024) should be limited to 1 Mb. Here are two responses I get:
But, when you change the limit to only 1024, which would be 1Kb everything is working fine. So, what could be the problem?!

Here are files I'm uploading, so you can see the're have matching file size:
Link to code that reproduces the bug
No response
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: