I am using node-formidable to upload multipart/formdata . Everything works fine as long as I
comment the line :
//app.use(express.bodyParser());
But the problem is that I want to implement a progress bar on the client side. For that I am trying to do something like this :
form.on('progress',function(a,b){
response.write() //Gives error saying Can't set headers after they have been sent
})
when I use the express bodyParser() res.write() works perfectly .
PS:I know this can be done using socket.io, but I dont think that is an elegant solution .
Is there a way to use response.write() and at the same time use formidable ?
Thank you.
with body parser you should be able to bind the 'data' event to the req object and then write to the res object with res.write().
I think you're sending response twice for that request. You can't do that simply in node. There are few workarounds. I'd suggest you read these two answers. It might help.
How to render multiple times on the same response object with ExpressJS?