Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to rename zip file nodejs

var AdmZip = require('adm-zip');

//create a zip object to hold the new zip files
var newZip = new AdmZip();

// reading archives
var zip = new AdmZip('somePath/download.zip');
var zipEntries = zip.getEntries(); // an array of ZipEntry records

zipEntries.forEach(function(zipEntry) {
    var fileName = zipEntry.entryName;
    var fileContent = zip.readAsText(fileName)
    //Here remove the top level directory
    var newFileName = fileName.substring(fileName.indexOf("/") + 1);

    newZip.addFile(newFileName, fileContent, '', 0644 << 16);        
});

newZip.writeZip('somePath/upload.zip');  //write the new zip 
Comment

PREVIOUS NEXT
Code Example
Javascript :: iterate over array of object javascript and access the properties 
Javascript :: simple nodejs server 
Javascript :: The reduce() method executes a reducer function on each element of the array and returns a single output value. 
Javascript :: ForEach Element with Function or Lambda 
Javascript :: add object to array javascript 
Javascript :: make shorter if statements with objects 
Javascript :: tailwind rn yarn install 
Javascript :: async await react stackoverflow 
Javascript :: currying javascript 
Javascript :: moment js date between two dates 
Javascript :: postgresql jsonb remove key 
Javascript :: next js get query parameters 
Javascript :: react onchange url 
Javascript :: js replace whole word and not words within words 
Javascript :: ubuntu apps to install 
Javascript :: angular add ellipsis to template string 
Javascript :: if and else shorthand 
Javascript :: js export options 
Javascript :: react-router in saga 
Javascript :: process.env type 
Javascript :: trim text 
Javascript :: js to find value in array 
Javascript :: javascript pipe function 
Javascript :: spread and rest javascript 
Javascript :: decode jwt tokens 
Javascript :: get array by array of indices js 
Javascript :: react validation form 
Javascript :: elif in js 
Javascript :: react router params and render 
Javascript :: array from javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =