When using Busboy with express to handle image uploads, I can get the fields and files of a multipart/form-data post like so:
var busboy = require('connect-busboy');
app.use(busboy());
app.post('/something', function(req,res) {
req.pipe(req.busboy);
req.busboy.on('field', function(fieldname, val) {
// do stuff here with fields...
}
req.busboy.on('file', function (fieldname, file, filename) {
// do stuff here with the file
}
});
What I'm wondering is, say there's an instance where I want to know what the fields are before I go about handling the file. It appears in my experimentation that the fields are gotten first every time. Does anyone know if this is guaranteed to always be the case?