{"action":"created","issue":{"url":"https://api.github.com/repos/mscdex/busboy/issues/91","labels_url":"https://api.github.com/repos/mscdex/busboy/issues/91/labels{/name}","comments_url":"https://api.github.com/repos/mscdex/busboy/issues/91/comments","events_url":"https://api.github.com/repos/mscdex/busboy/issues/91/events","html_url":"https://github.com/mscdex/busboy/issues/91","id":99348368,"number":91,"title":"node file upload middleware","user":{"login":"cesarvargas00","id":742797,"avatar_url":"https://avatars.githubusercontent.com/u/742797?v=3","gravatar_id":"","url":"https://api.github.com/users/cesarvargas00","html_url":"https://github.com/cesarvargas00","followers_url":"https://api.github.com/users/cesarvargas00/followers","following_url":"https://api.github.com/users/cesarvargas00/following{/other_user}","gists_url":"https://api.github.com/users/cesarvargas00/gists{/gist_id}","starred_url":"https://api.github.com/users/cesarvargas00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cesarvargas00/subscriptions","organizations_url":"https://api.github.com/users/cesarvargas00/orgs","repos_url":"https://api.github.com/users/cesarvargas00/repos","events_url":"https://api.github.com/users/cesarvargas00/events{/privacy}","received_events_url":"https://api.github.com/users/cesarvargas00/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-06T04:04:50Z","updated_at":"2015-08-06T13:55:14Z","closed_at":"2015-08-06T13:55:14Z","body":"Hi, I'm trying to create a middleware to easily access the files uploaded with busboy.\r\nThe problem is that im putting `next()` inside the `on('file')` callback. The problem with this is that\r\nwhenever I try to upload more than 1 file, since the event call will be async, \r\nI cannot guarantee that both files will be inside the `request.files` object.\r\n\r\nWell, I think the best place to put the `next()` call would be inside the `on('finish')` event callback.\r\nThe thing is, this method is not being called because I'm not handling the file stream: I'm just putting\r\nit inside the `request.files` object.\r\n\r\nPossible solutions:\r\n- Handle the Stream of all files and save them to disk. Then later pipe the disk content to whatever\r\n    place we want inside.\r\n- Use a timer and a counter. The timer keeps checking the counter to see if it is equal the\r\n    number of files that are being uploaded, if they are, just call `next()`.\r\n- Handle the Stream of all files and save them to Buffer variables. Save the variables inside the\r\n    `request.files`, and then call `next()` on the `on(finish)` event. Transform the buffer into readable Streams\r\n    and pipe them to a file or to mongodb.\r\n\r\nI think the better solution would be the latter, but I was wondering what's your opinions.\r\nso... What should I do?\r\n\r\nHere is the link to the git repository:\r\n\r\n[github.com/cesarvargas00/nodefu](http://github.com/cesarvargas00/nodefu)\r\n\r\nTake a look where I'm calling `next()` on line 53, and my question will probably be clearer."},"comment":{"url":"https://api.github.com/repos/mscdex/busboy/issues/comments/128373623","html_url":"https://github.com/mscdex/busboy/issues/91#issuecomment-128373623","issue_url":"https://api.github.com/repos/mscdex/busboy/issues/91","id":128373623,"user":{"login":"cesarvargas00","id":742797,"avatar_url":"https://avatars.githubusercontent.com/u/742797?v=3","gravatar_id":"","url":"https://api.github.com/users/cesarvargas00","html_url":"https://github.com/cesarvargas00","followers_url":"https://api.github.com/users/cesarvargas00/followers","following_url":"https://api.github.com/users/cesarvargas00/following{/other_user}","gists_url":"https://api.github.com/users/cesarvargas00/gists{/gist_id}","starred_url":"https://api.github.com/users/cesarvargas00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cesarvargas00/subscriptions","organizations_url":"https://api.github.com/users/cesarvargas00/orgs","repos_url":"https://api.github.com/users/cesarvargas00/repos","events_url":"https://api.github.com/users/cesarvargas00/events{/privacy}","received_events_url":"https://api.github.com/users/cesarvargas00/received_events","type":"User","site_admin":false},"created_at":"2015-08-06T13:55:14Z","updated_at":"2015-08-06T13:55:14Z","body":"@mscdex Thank you for the answer! I think I will use the reformed module for my application. Thanks!"}}