npm install node-zip
var fs = require('fs');
var path = require('path');
var zip = new require('node-zip')();
zip.file('some.txt', fs.readFileSync(path.join(__dirname, 'some.txt')));
var data = zip.generate({ base64:false, compression: 'DEFLATE' });
fs.writeFileSync('test.zip', data, 'binary');
zip.file('some.txt', fs.readFileSync(path.join(__dirname, 'some.txt')));
zip.file('some2.txt', fs.readFileSync(path.join(__dirname, 'some2.txt')));
npm install node-native-zip
var fs = require("fs");
var zip = require("node-native-zip");
var archive = new zip();
archive.add("one.txt", new Buffer("Hello world", "utf8"));
var buffer = archive.toBuffer();
fs.writeFile("./one.zip", buffer, function () {
console.log("Finished");
});
var zlib = require('zlib');
const gzip = zlib.createGzip();
const fs = require('fs');
const inp = fs.createReadStream('test.txt');
const out = fs.createWriteStream('text.txt.gz');
inp.pipe(gzip).pipe(out);
var zlib = require('zlib');
const gzip = zlib.createGzip();
const fs = require('fs');
const inp = fs.createReadStream('test.txt');
const out = fs.createWriteStream('text.txt.gz');
inp.pipe(gzip).pipe(out);