문제

I am using unzip module in Node.js for extracting archives.

unzip is working fine for .zip files but when I try to extract .rar files, the server is stopping unexpectedly.

fs.createReadStream(filepath).pipe(unzip.Extract({ path: folder }));

error:

Error: invalid signature: 0x5c3a4322
    at PATH_TO_MYPROJECT\node_modules\unzip\lib\parse.js:63:13
    at process._tickCallback (node.js:415:13)

The problem still persists even I put the whole code in a try/catch block.

try {
    fs.createReadStream(filepath).pipe(unzip.Extract({ path: folder }));
} catch(e) {
    //do something here...
}
도움이 되었습니까?

해결책

Zip and Rar are two differents file formats.

The library unzip only works with zip files, not with rar ones. You will need another library like tar.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top