I'd like to receive pictures, audio and video files with nodejs.
I send them via phonegap as a http-request.
With nodeJS I use the connect plugin. I really don't understand what it does and how to manipulate the location the files are getting stored.
var http = require('http');
var connect = require('connect');
var app = connect();
var server = http.createServer(app);
app.use(connect.bodyParser());
app.use(function(req, res) {
console.log(req.files); // Here is object with uploaded files
});
server.listen(8070);
How can I tell connect to store the files somewhere else as in the temp-directory.
And how can I read the requests options to decide where I want to store that file.
Here's what a file is about:
{ file:
{ fieldName: 'file',
originalFilename: 'VID_20131211_124140.mp4',
path: 'C:\\Users\\krause\\AppData\\Local\\Temp\\4120-1fx90bk.mp4',
headers:
{ 'content-disposition': 'form-data; name="file"; filename="VID_20131211_124140.mp4"',
'content-type': 'video/mp4' },
ws:
{ _writableState: [Object],
writable: true,
domain: null,
_events: [Object],
_maxListeners: 10,
path: 'C:\\Users\\krause\\AppData\\Local\\Temp\\4120-1fx90bk.mp4',
fd: null,
flags: 'w',
mode: 438,
start: undefined,
pos: undefined,
bytesWritten: 7046598,
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] },
size: 7046598,
name: 'VID_20131211_124140.mp4',
type: 'video/mp4' } }