wilton/zip
Read and write ZIP files
More...
Functions | |
Array | listFileEntries (String path, Function|Undefined callback) |
List all the entries names from a ZIP file. | |
Object | readFile (String path, Object|Undefined options, Function|Undefined callback) |
Read the entire contents of a ZIP file. | |
String | readFileEntry (String path, String entry, Object|Undefined options, Function|Undefined callback) |
Read the contents of a specified entry from a ZIP file. | |
Undefined | unzipFile (String path, String destPath, Function|Undefined callback) |
Unzip ZIP file into FS. | |
Undefined | unzipFileEntries (String path, Object entries, Function|Undefined callback) |
Unzip the specified ZIP entries into FS. | |
Undefined | writeFile (String path, Object entries, Object|Undefined options, Function|Undefined callback) |
Write the specified set of entries into ZIP file. |
This module allows to read and write files in ZIP format.
Usage example:
Array zip::listFileEntries | ( | String | path, |
Function|Undefined | callback | ||
) |
Reads a central directory record from a ZIP file and returns a list of ZIP entry names.
path | String path to file |
callback | Function|Undefined callback to receive result or error |
Array
list of ZIP entry names Object zip::readFile | ( | String | path, |
Object|Undefined | options, | ||
Function|Undefined | callback | ||
) |
Reads the entire contents of a ZIP file into "zip_entry_name" -> "zip_entry_contents" mapping. "zip_entry_contents" may be optionally encoded into hexadecimal (useful for binary data) if hex: true
option is specified.
path | String path to file |
options | Object|Undefined configuration object, can be omitted, see possible options below |
callback | Function|Undefined callback to receive result or error |
Object
"zip_entry_name" -> "zip_entry_contents" mappingOptions
Boolean
whether data read from ZIP entries needs to be converted to HEX format before returning it to caller; false
by default String zip::readFileEntry | ( | String | path, |
String | entry, | ||
Object|Undefined | options, | ||
Function|Undefined | callback | ||
) |
Reads the contents of a specified entry from a ZIP file. Resulting string may be optionally encoded into hexadecimal (useful for binary data) if hex: true
option is specified.
path | String path to file |
entry | String entry name inside the ZIP file |
options | Object|Undefined configuration object, can be omitted, see possible options below |
callback | Function|Undefined callback to receive result or error |
String
entry contentsOptions
Boolean
whether data read from specified ZIP entry needs to be converted to HEX format before returning it to caller; false
by default Undefined zip::unzipFile | ( | String | path, |
String | destPath, | ||
Function|Undefined | callback | ||
) |
Unzips all entries from the specified ZIP file into filesystem.
path | String path to file |
destPath | String path to the directory that will correspond to the root entry of the ZIP file |
callback | Function|Undefined callback to receive result or error |
Undefined
Undefined zip::unzipFileEntries | ( | String | path, |
Object | entries, | ||
Function|Undefined | callback | ||
) |
Takes the mapping of src_path_in_zip
-> dest_path_in_fs
and decompresses the specified entries to specifieed filesystems paths.
path | String path to file |
entries | Object src_path_in_zip -> dest_path_in_fs |
callback | Function|Undefined callback to receive result or error |
Undefined
Undefined zip::writeFile | ( | String | path, |
Object | entries, | ||
Object|Undefined | options, | ||
Function|Undefined | callback | ||
) |
Writes the specified "zip_entry_name" -> "zip_entry_contents" mapping into ZIP file. "zip_entry_contents" may be optionally decoded from hexadecimal (useful for binary data) if hex: true
option is specified.
Entries are sorted by keys in alphabetical order.
path | String path to file |
entries | Object "zip_entry_name" -> "zip_entry_contents" mapping |
options | Object|Undefined configuration object, can be omitted, see possible options below |
callback | Function|Undefined callback to receive result or error |
Undefined
Options
Boolean|Undefined
whether ZIP entry data needs to be converted to to HEX format before wrting it to ZIP file; false
by defaultBoolean|Undefined
whether ZIP entry data represents paths in filesystem that should be read and compressed into ZIP file; false
by default