Get download progress in Node.js with request -
i'm creating updater downloads application files using node module request
. how can use chunk.length
estimate remaining file size? here's part of code:
var file_url = 'http://foo.com/bar.zip'; var out = fs.createwritestream('baz.zip'); var req = request({ method: 'get', uri: file_url }); req.pipe(out); req.on('data', function (chunk) { console.log(chunk.length); }); req.on('end', function() { //do });
this should total want:
req.on( 'response', function ( data ) { console.log( data.headers[ 'content-length' ] ); } );
i content length of 9404541
Comments
Post a Comment