expressjs/multer — pull request #24 by dlin-me (2014-05-19 05:12:56+00:00)
Title: Fixed issue: call next() before uploaded file becomes accessible

Hi,

I found an intermittent issue when handling file uploads.
This is caused by the fact that busboy could emits the 'end' event before the writestream for uploaded file finalised ( 'finish' event ). This means the next middleware could have problem (ENOENT) accessing the uploaded file found in the 'req.files' object because the file might not be ready yet.

In my project, I experience 1 in 20 failure attempts when I am uploading many small files. This problem becomes obvious when the file system is busy.

I've patch the problem with minimal code. Please review and improve if you like.

Thanks.