The problem is that the 'finish' event is not what you expect. You are looking for the 'end' event.
the 'finish' event is fired when the busboy stream writable side is done writing. On Friday, 3 October 2014 15:27:10 UTC+2, [email protected] wrote: > > Hello,. > 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? > > My server code: > 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); > }); > > My console.log info: > 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/7cf2c145-9d46-40ef-82ba-f9fd7b75280f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
