node.js同步怎么解压文件

2025-03-20 21:33:08
推荐回答(1个)
回答1:

搜到一个只能解压缩的 https://github.com/nearinfinity/node-unzip
fs.createReadStream('path/to/archive.zip').pipe(unzip.Extract({ path: 'output/path' }));
var readStream = fs.createReadStream('path/to/archive.zip');var writeStream = fstream.Writer('output/path');fs.createReadStream('path/to/archive.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
var fileName = entry.path;
var type = entry.type; // 'Directory' or 'File'
var size = entry.size;

//process the entry or pipe it to another stream
...
});