Reputation: 35
I want to extract .tar.bz2 like the following with tar.gz with node.js:
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.");
});
The part "zlib.createGunzip()" should be replaced by a bz2-deflator. Does anyone know a working package for this issue?
Thanks
Upvotes: 4
Views: 3738
Reputation: 941
Use https://github.com/regular/unbzip2-stream.
Then https://github.com/mafintosh/tar-fs.
Not my repo.
Example:
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'));
Above example will extract foo.bar.bz2
into data/
directory.
Upvotes: 3
Reputation: 13725
They discuss the same issue here also: https://github.com/cscott/seek-bzip/issues/1
Upvotes: 0