app.post('/multiupload', function(req, res) {
var fstream;
var files = [];
var busboy = new Busboy({headers: req.headers});
busboy.on('file', function (fieldname, file, filename) {
fstream = fs.createWriteStream(__dirname + '/../static/uploaded/' + filename);
file.pipe(fstream);
fstream.on('close', function(){
console.log('file ' + filename + ' uploaded');
files.push(filename);
});
});
busboy.on('end', function(){console.log('END')});
busboy.on('finish', function(){
console.log('finish, files uploaded ', files);
res.redirect('back');
});
req.pipe(busboy);
});
file 111.gz uploaded
file 222.mp4 uploaded
file 333.jpg uploaded
finish, files uploaded [ '111.gz', '222.mp4', '333.jpg' ]
file 444 uploaded
file 555.jpg uploaded
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/2bb9066f-e117-4ed8-98b3-407ee4c4237b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/304c4d70-b57c-4f38-aa71-1856309a638a%40googlegroups.com.
You would probably need to use an async function to collect all the close events, to know exactly when all the files are saved.
I trying to upload few files through one input[type=file] with attribue 'multiple'. All work fine but 'finish' event firing before realy all work done. Does anyone know how to fix it?