質問

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