Would like to know how to extract tbz file with Node JS and save to disk. Sample code would be very appreciated.
Tried with something like this:
var zlib = require('zlib');
var fs = require('fs');
var file = fs.createReadStream('/tmp.tbz');
var zip = file.pipe(zlib.createUnzip());
zip.on("data", function(data) {
console.log(data);
});
zip.on("error",function(error){
console.log(error);
});
But end up with:
{ [Error: incorrect header check] errno: -3, code: 'Z_DATA_ERROR' }
Not sure I did this correctly.
Didn’t manage to find node library for extracting the tbz file, as I test with zlib,node-tar and etc. Eventually come out with this hack using ‘tar’ command.
I temporary accept my answer, until better one comes.