Q:

How do you zip a file in node.js?

0

How do you zip a file in node.js

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Solution

Node.js provides Zlib module to zip a file. The given example demonstrates this -

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

var gzip = zlib.createGzip();
var r = fs.createReadStream('./demofile.txt');
var w = fs.createWriteStream('./demogzipfile.txt.gz');
r.pipe(gzip).pipe(w);

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now