Jim Wang
Jim Wang

Reputation: 123

Uploading file using Node to a stream without first writing to temp file disk?

Is there a way to stream directly to a remote server or fileshare when handling Node.js file uploads? I'm using formidable and currently I am trying to enable this scenario, but it always ends up writing to a temp file on my server first, which in my mind is unnecessary if the ultimate destination is a remote server.

I also tried connect-form which is built on top of formidable, but didn't find any good documentation for onPart/handlePart, which I assume allows me to do this. Does anybody have a pointer to a good example which enables this scenario?

Upvotes: 5

Views: 1771

Answers (2)

tokland
tokland

Reputation: 67900

Not the stream, but you can get the string contents of the uploaded file (it will be stored at req.body.input_name) this way:

app.use(express.bodyParser({keepExtensions: true, _fileName: function() { }}));

Upvotes: 0

Jim Wang
Jim Wang

Reputation: 123

Turns out the Formidable team is working on making this scenario much easier with Node.js streams. When the issue is fixed this will become much easier.

https://github.com/felixge/node-formidable/issues/61

Upvotes: 1

Related Questions