Node.js zlib compress text file to .gz file

Description

Node.js zlib compress text file to .gz file


var fs = require('fs');
var zlib = require('zlib');

// Compress the file input.tx to input.txt.gz
fs.createReadStream('input.txt')
  .pipe(zlib.createGzip())//from  w  w w.jav  a2s.  co m
  .pipe(fs.createWriteStream('input.txt.gz'));
console.log('File Compressed');



PreviousNext

Related