To download and unzip files in Node.js cross-platform, we use the zlib library.
For instance, we write
const zlib = require("zlib");
zlib.gunzip(gzipBuffer, (err, result) => {
if (err) {
return console.error(err);
}
console.log(result);
});
to call gunzip to unzip the gzipBuffer file.
We get the unzipped file from the result parameter in the callback.