현재 adm-zip
을 사용하여 특정 경로에 압축 파일을 추출하지만 extractAllTo
메서드는 동기식입니다.Nodejs가 비동기식으로 zip을 추출합니다.
비동기식으로 zip 파일을 추출 할 수있는 방법이 있습니까?
현재 adm-zip
을 사용하여 특정 경로에 압축 파일을 추출하지만 extractAllTo
메서드는 동기식입니다.Nodejs가 비동기식으로 zip을 추출합니다.
비동기식으로 zip 파일을 추출 할 수있는 방법이 있습니까?
NPM에 비동기 압축 해제 라이브러리를 사용해보십시오 : https://www.npmjs.com/package/async-unzip
이 인 메모리 작동하고, 100 % 비동기, 이것은 당신이 = 원하는 행동) 여기
를 얻을 것이다 것은 예입니다 :
var async = require('async'),
path = require('path'),
ZipFile = require('async-unzip').ZipFile,
zipFile = new ZipFile('/home/user/Name.app.dSYM.zip'),
noMoreFiles = false;
async.whilst(function() {
return !noMoreFiles;
}, function (cb) {
async.waterfall([
function (cb) {
zipFile.getNextEntry(cb);
},
function (entry, cb) {
if (entry) {
if (entry.isFile) {
var match = entry.filename.match(/^[^\/]+\.dSYM\/Contents\/Resources\/DWARF\/(.+)/);
if (match) {
console.log(match);
console.log(entry);
async.waterfall([
function (cb) {
entry.getData(cb);
},
function (data, cb) {
// `data` is a binary data of the entry.
console.log(data.length);
cb();
}
], cb);
}
}
} else {
noMoreFiles = true;
}
cb();
}
], cb);
}, function() {
// DO NOT FORGET to call `close()` to release the open file descriptor,
// otherwise, you will quickly run out of file descriptors.
zipFile.close();
console.log(arguments);
});
'async-unzip' 패키지에 github (NPM 페이지 당) 소스가없는 것 같습니다. . 다른 곳에서 호스팅됩니까? – scorpiodawg
잘 모르겠다. 나는 단지 npm을 통해 그것을 읽고 사용했다. – rdegges
전체 라이브러리가 동기식 인 것처럼 보입니다. – loganfsmyth
내 동등한 것 같아요. – rzr
제 질문이 업데이트되었습니다. 비동기식도 알고 싶습니다. – rzr