busboy doesn't error when over limit?
See original GitHub issueI’ve got a busboy with options:
var busboyParser = busboy({
limits: {
fileSize: 1000000, // 1 mb
files: 2,
}
});
My code is basically from the README:
if (req.busboy) {
req.busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
var saveTo = path.join(os.tmpDir(), path.basename(fieldname));
console.log("saved to " + saveTo);
file.resume();
});
req.busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated) {
console.log('Field [' + fieldname + ']: value: ' + val);
});
req.busboy.on('finish', function() {
console.log('Done parsing form!');
});
req.busboy.on('error', function() {
console.log("ERROR");
});
req.pipe(req.busboy);
}
But if I upload a file that’s over 1MB or upload more than 2 files, busboy won’t throw any errors. Instead busboy just proceeds to process the file(s):
Field [flowChunkNumber]: value: 3
Field [flowChunkSize]: value: 1048576
Field [flowCurrentChunkSize]: value: 1048576
Field [flowTotalSize]: value: 8210139
Field [flowIdentifier]: value: 8210139-guidepdf
Field [flowFilename]: value: guide.pdf
Field [flowRelativePath]: value: guide.pdf
Field [flowTotalChunks]: value: 7
saved to /tmp/file
Done parsing form!
How should I handle errors relating to the defined limits?
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Avoiding further processing on busyboy file upload size limit
I'm trying to set an upload limit in busboy. Without upload limit i'm able to upload the file successfully. But when i want...
Read more >busboy - npm
A streaming parser for HTML form data for node.js. Latest version: 1.6.0, last published: 8 months ago. Start using busboy in your project ......
Read more >@fastify/busboy | Yarn - Package Manager
Description. A Node.js module for parsing incoming HTML form data. This is an officially supported fork by fastify organization of the amazing library ......
Read more >Fix "Unexpected field" Error From Multer - Maxim Orlov
By now you've already spent several hours trying to solve this problem. Why does implementing a simple file upload feature have to be...
Read more >Node.js Express File Upload Rest API example using Multer
uploading File to a static folder in the Server (restrict file size: 2MB) ... use middleware function for file upload; catch Multer error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There is no event for fileSize limit?
@sam1111 You can simply unpipe busboy from the source stream if you want to halt parsing and possibly call
busboy.removeListener('finish', myFinishListener)
.