"Finish" and "field" events does not work when "file" event is added.
See original GitHub issueFor eg:
This works!
const registerBusboyFields = (req, res, next) => {
req.uploadBody = {};
req.busboy.on("field", function (name, value) {
req.uploadBody[name] = value;
console.log(name, value);
});
// Finished all busboy events
req.busboy.on("finish", () => {
// The finish event is triggered...
console.log(req.uploadBody);
next();
});
req.pipe(req.busboy);
};
This does not work 😦
const registerBusboyFields = (req, res, next) => {
req.uploadBody = {};
req.busboy.on("file", function (name, file, info) {
req.uploadBody[name] = info;
console.log(info);
});
req.busboy.on("field", function (name, value) {
req.uploadBody[name] = value;
console.log(name, value);
});
// Finished all busboy events
req.busboy.on("finish", () => {
// The finish event is NOT triggered...
console.log(req.uploadBody);
next();
});
req.pipe(req.busboy);
};
PS: When i say “does not work”, i mean, i just see the console.log happening on “file” event, but console.log does neither happen on “field” event not in “finish” event.
Am I doing something wrong?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
busboy not firing finish event - Stack Overflow
So, what i see that both the fields and the files are being logged in console but the finish event is not getting...
Read more >busboy, upload few files, 'finish' event doesn't work properly
I trying to upload few files through one input[type=file] with attribue 'multiple'. All work fine but 'finish' event firing before realy all ...
Read more >Known Issues - The Events Calendar
To do this, open the event and change the start date or start time, and hit Update. Then change the date or time...
Read more >Event File Not Found After Importing
Event File Not Found After Importing · Click File · Click Import · Click Meet Events · Double-click the event file · Click...
Read more >Handling Events :: Eloquent JavaScript
This works for most types of events—you can attach a handler through the attribute whose name is the event name with on in...
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
Assuming the filename is coming from the file part, then no. If the filename is being transmitted separately from the file part, as a normal field (
'field'
event), then obviously yes.Also FWIW, in general filenames given by a user/client in forms should rarely be used as-is as they could contain a malicious value.
file
is a readable stream. You have to read all of its contents whether you care about them or not in order for the form parsing to complete.