Node XHR file upload events
Consider an ExpressJS app which receives file uploads:
app.post('/api/file', function(req, res) {
req.on('data', function() {
console.log('asd')
})
})
I can't understand why data event is never fired. I'm also using
bodyParser() middleware which gives me the following object for each file
which seems to have some events available but still no effect:
{
file: {
domain: null,
_events: {},
_maxListeners: 10,
size: 43330194,
path: 'public/uploads/a4abdeae32d56a2494db48e9b0b22a5e.deb',
name: 'google-chrome-stable_current_amd64.deb',
type: 'application/x-deb',
hash: null,
lastModifiedDate: Sat Aug 24 2013 20: 59: 00 GMT + 0200(CEST),
_writeStream: {
_writableState: [Object],
writable: true,
domain: null,
_events: {},
_maxListeners: 10,
path: 'public/uploads/a4abdeae32d56a2494db48e9b0b22a5e.deb',
fd: null,
flags: 'w',
mode: 438,
start: undefined,
pos: undefined,
bytesWritten: 43330194,
closed: true,
open: [Function],
_write: [Function],
destroy: [Function],
close: [Function],
destroySoon: [Function],
pipe: [Function],
write: [Function],
end: [Function],
setMaxListeners: [Function],
emit: [Function],
addListener: [Function],
on: [Function],
once: [Function],
removeListener: [Function],
removeAllListeners: [Function],
listeners: [Function]
},
open: [Function],
toJSON: [Function],
write: [Function],
end: [Function],
setMaxListeners: [Function],
emit: [Function],
addListener: [Function],
on: [Function],
once: [Function],
removeListener: [Function],
removeAllListeners: [Function],
listeners: [Function]
}
}
I would like to understand how to make progress and complete events work.
No comments:
Post a Comment