Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

npm adm-zip

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

// reading archives
var zip = new AdmZip("./my_file.zip");
var zipEntries = zip.getEntries(); // an array of ZipEntry records

zipEntries.forEach(function (zipEntry) {
    console.log(zipEntry.toString()); // outputs zip entries information
    if (zipEntry.entryName == "my_file.txt") {
        console.log(zipEntry.getData().toString("utf8"));
    }
});
// outputs the content of some_folder/my_file.txt
console.log(zip.readAsText("some_folder/my_file.txt"));
// extracts the specified file to the specified location
zip.extractEntryTo(/*entry name*/ "some_folder/my_file.txt", /*target path*/ "/home/me/tempfolder", /*maintainEntryPath*/ false, /*overwrite*/ true);
// extracts everything
zip.extractAllTo(/*target path*/ "/home/me/zipcontent/", /*overwrite*/ true);

// creating archives
var zip = new AdmZip();

// add file directly
var content = "inner content of the file";
zip.addFile("test.txt", Buffer.from(content, "utf8"), "entry comment goes here");
// add local file
zip.addLocalFile("/home/me/some_picture.png");
// get everything as a buffer
var willSendthis = zip.toBuffer();
// or write everything to disk
zip.writeZip(/*target file name*/ "/home/me/files.zip");

// ... more examples in the wiki
Comment

PREVIOUS NEXT
Code Example
Javascript :: owl carousel next previous button 
Javascript :: scrapy javascript 
Javascript :: 12 hours to 24 hours javascript 
Javascript :: unsubscribe all youtube channel using javascript 
Javascript :: custom attribute jquery selector 
Javascript :: js call function by string name 
Javascript :: remove double quotes from json array javascript 
Javascript :: react-router-dom redirect 
Javascript :: scroll to div js 
Javascript :: Access to XMLHttpRequest has been blocked by CORS policy 
Javascript :: add multiple event listeners 
Javascript :: npm chalk 
Javascript :: add value to each object in array javascript 
Javascript :: foreach loop javascript 
Javascript :: check to see if work is uppercase javascript 
Javascript :: add new element useState array 
Javascript :: express public folder 
Javascript :: stripe react js 
Javascript :: for of loop javascript 
Javascript :: ajax syntax in javascript 
Javascript :: js clear all select options 
Javascript :: expo react native send image to api 
Javascript :: for in 
Javascript :: check if two rectangles overlap javascript canvas 
Javascript :: jquery fade out 
Javascript :: node js load css file 
Javascript :: how to get array from number length 
Javascript :: how to filter out undefined keys from object in js 
Javascript :: How to make blinking/flashing text with jQuery 
Javascript :: jquery show password 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =