So what are the pros and cons of using bodyParser for file uploads?
I mean with bodyParser I get the file into a /var/ directory and then I move it to my directory once its uploaded, it gives me easy access to the name file and other information, but without bodyParser I can do stuff to the files once the 'done' event is triggered..
Is there a way to know when to use bodyParser, and when no to when it comes to files?
If you are working with express, you are able to bind a middleware before the bodyParser.
Something like this:
app.use( function( req, res, next ) {
... code here runs before bodyparser
next();
... code here runs on the way back (only when there is no error)
});
app.use( express.bodyParser() );
app.use( function( req, res, next ) {
... code here runs after bodyparser, before route
next();
... code here runs on the way back (only when there is no error)
});
In this case, you would be able to use both.
Best regards Robert