我想从我的 GitLab 存储库下载(而不是克隆)存档,但我收到此错误
不正确的标头检查 (Zlib._handle.onerror)
这是我的功能:
var fs = require('fs');
var url = require('url');
var https = require('https');
var path = require('path');
var targz = require('tar.gz');
function downloadFile(source, destination, name) {
var options = {
host: url.parse(source).host,
port: 443,
path: url.parse(source).pathname
};
var file = fs.createWriteStream(destination + path.sep + name);
https.get(options, function(res) {
res.on('data', function(data) {
file.write(data);
}).on('end', function() {
file.end();
console.log('File ' + name + ' downloaded to ' + destination);
targz().extract(destination + '/' + name, destination)
.then(function(){
console.log('Job done!');
})
.catch(function(err){
console.log('Something is wrong ', err.stack);
});
});
});
}
下载的文件类型为 tar.gz。我尝试设置一些标题但不成功。源参数就像:https ://gitlab.com/api/v3/projects/:ID/repository/archive?token=XXYYZZ
请问有什么帮助吗?