Get download progress in Node.js with request

前端 未结 6 2241
清酒与你
清酒与你 2020-12-02 15:27

I\'m creating an updater that downloads application files using the Node module request. How can I use chunk.length to estimate the remaining file

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 16:21

    This should get you the total you want:

    req.on( 'response', function ( data ) {
        console.log( data.headers[ 'content-length' ] );
    } );
    

    I get a content length of 9404541

提交回复
热议问题