}, (err, res, body) => { if(!err) { var bodyStream = streamifier.createReadStream(body); bodyStream.pipe( unzip.Extract({ path: opts.path }) ) } callback && callback(err); });
return new Promise((resolve, reject) => { fs.createReadStream(filePath) .on("error", function (error: string) { reject(error); }) .on("close", function () { resolve(); }) .pipe(unzip.Extract({path: targetDirectory})); });
import * as unzip from 'unzip'; import * as fs from 'fs'; fs.createReadStream('path/to/archive.zip') .pipe(unzip.Extract({ path: 'output/path' })); fs.createReadStream('path/to/archive.zip') .pipe(unzip.Parse()) .on('entry', (entry: unzip.Entry) => { const fileName = entry.path; const type = entry.type; // 'Directory' or 'File' const size = entry.size; if (fileName === "this IS the file I'm looking for") { entry.pipe(fs.createWriteStream('output/path')); } else { entry.autodrain(); } });
.then(zip => { var buffer = zip.generate({ type: "nodebuffer" }); var bufferStream = new stream.PassThrough(); bufferStream.end( buffer ); bufferStream.pipe(unzip.Extract({ path: `${vscode.workspace.rootPath}/src` })); });