Simplest way to download and unzip files in Node.js cross-platform?

前端 未结 11 1581
一个人的身影
一个人的身影 2020-11-30 23:44

Just looking for a simple solution to downloading and unzipping .zip or .tar.gz files in Node.js on any operating system.

Not sure if this

11条回答
  •  无人及你
    2020-11-30 23:54

    I found success with the following, works with .zip
    (Simplified here for posting: no error checking & just unzips all files to current folder)

    function DownloadAndUnzip(URL){
        var unzip = require('unzip');
        var http = require('http');
        var request = http.get(URL, function(response) {
            response.pipe(unzip.Extract({path:'./'}))
        });
    }
    

提交回复
热议问题