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

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -