gpt4 book ai didi

node.js - 使用 Node.js 提取 .bz2 管道?

转载 作者:行者123 更新时间:2023-12-02 11:17:32 25 4
gpt4 key购买 nike

我想使用node.js使用tar.gz提取.tar.bz2,如下所示:

request.get("localhost/file.tar.gz")
.pipe(zlib.createGunzip())
.pipe(tar.Extract({path: "./test"}))
.on("error", function(err){
console.log("Error on extract", err);
})
.on("end", function(){
console.log("done.");
});

“zlib.createGunzip()”部分应替换为 bz2-deflator。有谁知道这个问题的工作包吗?

谢谢

最佳答案

使用https://github.com/regular/unbzip2-stream .

然后https://github.com/mafintosh/tar-fs .

不是我的仓库。

示例:

const fs = require('fs');
const bz2 = require('unbzip2-stream');
const tarfs = require('tar-fs');

fs.createReadStream('foo.tar.bz2').pipe(bz2()).pipe(tarfs.extract('data'));

上面的示例会将 foo.bar.bz2 提取到 data/ 目录中。

关于node.js - 使用 Node.js 提取 .bz2 管道?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14655582/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com