-
Notifications
You must be signed in to change notification settings - Fork 375
ADM ZIP
-
adm-zip.js
- constructor(filePath)
- getEntries()
- getEntry(name)
- readFile(entry)
- readFileAsync(entry, callback)
- readAsText(entry, encoding)
- readAsTextAsync(entry, callback, encoding)
- deleteFile(entry)
- addZipComment(comment)
- getZipComment( )
- addZipEntryComment(entry, comment)
- getZipEntryComment(entry)
- updateFile(entry, content)
- addLocalFile(localPath, zipPath)
- addLocalFolder(localPath, zipPath)
- addFile(entryName, content, comment, attr)
- extractEntryTo(entry, targetPath, maintainEntryPath, overwrite)
- extractAllTo(targetPath, overwrite)
- writeZip(targetFileName)
- toBuffer()
var Zip = require("adm-zip");
If no argument is specified, then a new in memory zip will be created
Examples:
// loads and parses existing zip file local_file.zip
var zip = new Zip("local_file.zip");
// creates new in memory zip
var zip = new Zip();
The entry
argument can be either a ZipEntry object or String with the entry name.
The entry
argument can be either a ZipEntry object or String with the entry name.
Examples:
// loads and parses existing zip file local_file.zip
var zip = new Zip("local_file.zip");
// get all entries and iterate them
zip.getEntries().forEach(function(entry) {
var entryName = entry.entryName;
var decompressedData = zip.readFile(entry); // decompressed buffer of the entry
console.log(zip.readAsText(entry)); // outputs the decompressed content of the entry
});
The entry
argument can be either a ZipEntry object or String with the entry name.
The entry
argument can be either a ZipEntry object or String with the entry name.
The entry
argument can be either a ZipEntry object or String with the entry name.
The entry
argument can be either a ZipEntry object or String with the entry name.
If you want to create a directory the entryName
must end in / and a null buffer should be provided.
comment
and attributes
are optional.
The entry
argument can be either a ZipEntry object or String with the entry name.
If maintainEntryPath
is TRUE and the entry is inside a folder, the entry folder will be created in targetPath as well.
If the files to be extracted already exist at the target path, the files may be overwritten if specified so by the overwrite
argument
// will extract the file myfile.txt from the archive to /home/user/folder/subfolder/myfile.txt
zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", true, true);
// will extract the file myfile.txt from the archive to /home/user/myfile.txt
zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", false, true);
If the files to be extracted already exist at the target path, the files may be overwritten if specified so by the overwrite
argument