Node.js File Upload (Express 4, MongoDB, GridFS, GridFS-Stream) Node.js File Upload (Express 4, MongoDB, GridFS, GridFS-Stream) mongodb mongodb

Node.js File Upload (Express 4, MongoDB, GridFS, GridFS-Stream)


See my comment on the issue you created on github. I had the same problem but I managed to debug the issue. I narrowed it down to where i was confident that the problem was a piece of express middleware modified the request. I disabled my middleware one by one until i found the unlikely culprit: connect-livereload

I commented out app.use(require('connect-livereload')()); and the problem went away.I believe it was injecting the livereload script into the response (a binary image file).


Looks like the file has been uploaded through an HTML form, in that case you need to decode the multipart/form-data encoded data, re-assemble the parts if needed and save the file to GridFS. For parsing, you can use something like node-multiparty.