How can I intercept a multipart file stream in Express.js?

express, multipartform-data, node.js

Solution

You can't, unless you make a middleware that uses formidable and intercept the stream there (a solution would be to change the bodyParser used by Express with a custom one).

Check out for yourself in the following file: ~https://github.com/senchalabs/connect/blob/master/lib/middleware/multipart.js~ dead link

Notice there's no 'global' event that you can hook into.

Problem

Following the example ~https://github.com/visionmedia/express/blob/master/examples/multipart/app.js~ dead link Express.js seems to do all the work behind the scenes and saves the file and gives it to you whole. How can I intercept and manipulate the raw stream? Specifically I would like to get the stream so I can hook it up to a write stream.

Original source