1var AdmZip = require('adm-zip');
2
3//create a zip object to hold the new zip files
4var newZip = new AdmZip();
5
6// reading archives
7var zip = new AdmZip('somePath/download.zip');
8var zipEntries = zip.getEntries(); // an array of ZipEntry records
9
10zipEntries.forEach(function(zipEntry) {
11 var fileName = zipEntry.entryName;
12 var fileContent = zip.readAsText(fileName)
13 //Here remove the top level directory
14 var newFileName = fileName.substring(fileName.indexOf("/") + 1);
15
16 newZip.addFile(newFileName, fileContent, '', 0644 << 16);
17});
18
19newZip.writeZip('somePath/upload.zip'); //write the new zip
20