从nodejs中的服务器下载后,Zip文件已损坏

时间:2017-02-01 06:16:42

标签: node.js node.js-stream

var fileUrl = "http://twitter.github.com/bootstrap/assets/bootstrap.zip";
var output = "bootstrap.zip";
request({url: fileUrl, encoding: null}, function(err, resp, body) {
  if(err) throw err;
  fs.writeFile(output, body, function(err) {
    console.log("file written!");
  });
});

在这段代码中我们将zip文件下载为zip并支持。但是不支持或者文件可能因下载其他格式而损坏,如jpg,csv ...

0 个答案:

没有答案
相关问题