req.pipe(zlib.createGunzip()).pipe(tar.extract()) .on('entry', function (entry, stream, next) { if (entry.type === 'file') {
readStream // reads current file .pipe(gunzip) // de-compresses .pipe(decryptStream) // decrypts .pipe(writeStream) // writes to out file .on('finish', function () { // all done console.log('Decription and decompression done successfully.'); });
http.createServer((req, res) => { const { filename } = req.headers console.log(`File request received: ${filename}`) req .pipe(crypto.createDecipher('aes-192-gcm', 'secret')) .pipe(zlib.createGunzip()) .pipe(fs.createWriteStream(filename)) .on('finish', () => { res.writeHead(201, { 'Content-Type': 'text/plain' }) res.end('That\'s it\n') console.log(`File saved: ${filename}`) }) })
const extractTar = (parts, outdir) => { return new Promise((resolve, reject) => { const unpack = merge2(...parts.map(part => fs.createReadStream(part))) .pipe(zlib.createGunzip()) .pipe(tar.extract(outdir)); unpack.on('finish', () => resolve()); unpack.on('error', e => reject(e)); }); }
downloadExpandNodeSource() { const url = `https://nodejs.org/dist/v${this.version}/node-v${this.version}.tar.gz`; if(fs.existsSync(this.nodePath('configure'))) { log(`node version=${this.version} already downloaded and expanded, using it`); return Promise.resolve(); } return download(url, this.nodeSrcFile) .then(() => new Promise((resolve, reject) => { log(`expanding node source, file=${this.nodeSrcFile} ...`); fs.createReadStream(this.nodeSrcFile) .pipe(createGunzip()) .pipe(tar.extract(dirname(this.nodeSrcFile))) .on('error', reject) .on('finish', resolve) }) ); }
async function checkAndDownload() { console.log(`Checking if build tdlib-v${tdlib.version}-${tdlib.commit}-${tdlib.variant}-${arch_version} exist...`) let head = await rp({ method: 'HEAD', url: tdlib.debug ? url.debug : url.main, resolveWithFullResponse: true, simple: false, followRedirect: false }) if (head.statusCode == 301 || head.statusCode == 302) { console.log('Build exist. Downloading...') rp.get(tdlib.debug ? url.debug : url.main).pipe(zlib.createGunzip()).pipe(fs.createWriteStream('./tdlib.node')).on('finish', () => { process.exit(0) }) } else { console.log('Build does not exist. Trying to compile...') process.exit(1) } }
ts.on('error', error => console.error('PS ERROR!', error))
process.send(['import-failed', 'gz-extract']); //mainWindow.webContents.send('upd-dump-failed', 'gz-extract'); console.log(err); }).pipe(unzip).pipe(out); }) .once('close', function () {
/** * Find the list of file names in the specified chaincode deployment specification. * @private * @param {ChaincodeDeploymentSpec} chaincodeDeploymentSpec The chaincode deployment specification. * @returns {string[]} The list of file names. */ static async _findFileNames(chaincodeDeploymentSpec) { const codePackage = chaincodeDeploymentSpec.getCodePackage().toBuffer(); const gunzip = zlib.createGunzip(); const extract = tar.extract(); return new Promise((resolve) => { const fileNames = []; extract.on('entry', (header, stream, next) => { logger.debug('Package._findFileNames - found entry %s', header.name); fileNames.push(header.name); stream.on('end', () => { next(); }); stream.resume(); }); extract.on('finish', () => { resolve(fileNames.sort()); }); gunzip.pipe(extract); gunzip.end(codePackage); }); }
.pipe(ndjson.parse()) .on('data', function (data) { const type = Object.keys(data)[0]
.pipe(ndjson.parse()) .on('data', function (data) { const type = Object.keys(data)[0]
.pipe(ndjson.parse()) .on('data', function (data) { const type = Object.keys(data)[0]
/** * Find the list of file names in the specified chaincode deployment specification. * @private * @param {ChaincodeDeploymentSpec} chaincodeDeploymentSpec The chaincode deployment specification. * @returns {string[]} The list of file names. */ static async _findFileNames(chaincodeDeploymentSpec) { const codePackage = chaincodeDeploymentSpec.getCodePackage().toBuffer(); const gunzip = zlib.createGunzip(); const extract = tar.extract(); return new Promise((resolve) => { const fileNames = []; extract.on('entry', (header, stream, next) => { logger.debug('Package._findFileNames - found entry %s', header.name); fileNames.push(header.name); stream.on('end', () => { next(); }); stream.resume(); }); extract.on('finish', () => { resolve(fileNames.sort()); }); gunzip.pipe(extract); gunzip.end(codePackage); }); }