Does anyone have any example code for piping a file from the client to the server?
+1
Sure, it's straight up node streams:
var assert = require('assert');
var fs = require('fs');
var restify = require('restify');
var server = restify.createServer();
server.put('/:name', function (req, res, next) {
var stream = fs.createWriteStream('/tmp/' + req.params.name);
req.pipe(stream);
req.once('end', function () {
console.log('srv: responding');
res.send(204);
});
next();
});
server.listen(8080, function () {
var client = restify.createClient({
url: 'http://localhost:8080'
});
console.log('client: sending');
client.put('/words', function (err, req) {
assert.ifError(err);
fs.createReadStream('/usr/dict/words').pipe(req);
req.once('result', function (err) {
assert.ifError(err);
console.log('client: got response');
server.close();
});
});
});
Hi, it looks like the current version of Restify doesn't support streaming the request. If I pipe the request to a writeable stream I get nothing out of it. Did this change???
No, streaming is definitely supported. Can you show me a code snippet?
On Wed, Dec 4, 2013 at 1:47 PM, jalanhunt [email protected] wrote:
Hi, it looks like the current version of Restify doesn't support streaming
the request. If I pipe the request to a writeable stream I get nothing out
of it. Did this change???—
Reply to this email directly or view it on GitHubhttps://github.com/mcavage/node-restify/issues/218#issuecomment-29849018
.
My apologies - this wasn't a restify bug. Nevermind. :)
On Wed, Dec 4, 2013 at 1:54 PM, Mark Cavage [email protected]:
No, streaming is definitely supported. Can you show me a code snippet?
On Wed, Dec 4, 2013 at 1:47 PM, jalanhunt [email protected]
wrote:Hi, it looks like the current version of Restify doesn't support
streaming
the request. If I pipe the request to a writeable stream I get nothing
out
of it. Did this change???—
Reply to this email directly or view it on GitHub<
https://github.com/mcavage/node-restify/issues/218#issuecomment-29849018>
.—
Reply to this email directly or view it on GitHubhttps://github.com/mcavage/node-restify/issues/218#issuecomment-29849615
.
Jeffrey Hunt
Web Application Consulting & Development
Mobile: +1 (415) 513-6679
Email: [email protected]
Actually, I found that using the restify bodyparser makes it so that the
incoming request can't be streamed... I don't know if this is mentioned in
the Restify docs & if it's worth mentioning...
On Wed, Dec 4, 2013 at 6:54 PM, Jeffrey Hunt [email protected] wrote:
My apologies - this wasn't a restify bug. Nevermind. :)
On Wed, Dec 4, 2013 at 1:54 PM, Mark Cavage [email protected]:
No, streaming is definitely supported. Can you show me a code snippet?
On Wed, Dec 4, 2013 at 1:47 PM, jalanhunt [email protected]
wrote:Hi, it looks like the current version of Restify doesn't support
streaming
the request. If I pipe the request to a writeable stream I get nothing
out
of it. Did this change???—
Reply to this email directly or view it on GitHub<
https://github.com/mcavage/node-restify/issues/218#issuecomment-29849018>.
—
Reply to this email directly or view it on GitHubhttps://github.com/mcavage/node-restify/issues/218#issuecomment-29849615
.
Jeffrey Hunt
Web Application Consulting & Development
Mobile: +1 (415) 513-6679
Email: [email protected]
Jeffrey Hunt
Web Application Consulting & Development
Mobile: +1 (415) 513-6679
Email: [email protected]
Most helpful comment
Actually, I found that using the restify bodyparser makes it so that the
incoming request can't be streamed... I don't know if this is mentioned in
the Restify docs & if it's worth mentioning...
On Wed, Dec 4, 2013 at 6:54 PM, Jeffrey Hunt [email protected] wrote:
Jeffrey Hunt
Web Application Consulting & Development
Mobile: +1 (415) 513-6679
Email: [email protected]