Вы должны использовать пакет jszip npm.Это позволяет быстро читать zip-файлы.
Пример:
var fs = require("fs");
var JSZip = require("jszip");
// read a zip file
fs.readFile("project.zip", function(err, data) {
if (err) throw err;
JSZip.loadAsync(data).then(function (zip) {
files = Object.keys(zip.files);
console.log(files);
});
});
To read the contents of a file in the zip archive you can use the following.
// read a zip file
fs.readFile("project.zip", function(err, data) {
if (err) throw err;
JSZip.loadAsync(data).then(function (zip) {
// Read the contents of the 'Hello.txt' file
zip.file("Hello.txt").async("string").then(function (data) {
// data is "Hello World!"
console.log(data);
});
});
});
и загружать zip-файлы с сервера:
request('yourserverurl/helloworld.zip')
.pipe(fs.createWriteStream('helloworld.zip'))
.on('close', function () {
console.log('File written!');
});