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

标签 node.js stream gzip tar bzip2

我想使用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/

相关文章:

actionscript-3 - 如何从 ActionScript 3 中的缓冲区 (ByteArray/Stream) 播放 MP3 声音?

python-3.x - 在 Python 中修改 gzip xml 文件(Adobe Premiere Pro 项目文件)的更快方法?

java - 将zip文件转换为gzip并写入hdfs

mysql - 如何将原始查询(Sequelize)的结果返回到 GraphQL

c - 通过 c 中的管道而不是文件将数据数组传递给 gnuplot

c# - 使用 TCP 在 C# 中实现 FTP 客户端

http - 我如何判断 Heroku 是否正在发送 gzip 压缩响应?

node.js - 如何在 Express 中获取所有已注册的路线?

node.js - Express 4、NodeJS、AngularJS 路由

node.js - Node : could not initialize ICU (check NODE_ICU_DATA or --icu-data-dir parameters)