node.js - koa.js streaming response from remote url -
i want create koa
route acts proxy url, delivers file few dozens of megabytes.
therefore not block when making response. using this.body = yield request.get(url);
currently, request [co-request
]1 module.
how stream response client ?
edit :
i doing following :
var req = require('request'); //... this.body = req(url).pipe(fs.createwritestream(this.params.what));
if paste url
in browser, file fine. if error: cannot pipe. not readable.
in route.
turns out solution :
var req = require('request'); //... this.body = req(url);
this because this.body
has readable stream, req(url)
returns. @danneu explanation.
Comments
Post a Comment