JSZip@2 / PizZip compatible synchronous ZIP archives operations.
Differences from JSZip@2 / PizZip:
- can load from file if data is string and options.base64=false. In this case file content is NOT loaded into memory wholly, but only headers is loaded first. After access to file inside archive - only this file content is loaded into memory
- can generate into file. In this case data is written using buffers, so zip content can be huge
# new UZip ()
Members
# files : Object instance
Files in archive. Keys is file names (including folders)
Methods
# file (fn: string | RegExp, dataopt: string | ArrayBuffer | Uint8Array | UBMail.TubSendMailAttachKind.Buffer, oopt: object) → UZip | object | Array instance
Add a file to the archive, or search a file.
Return:
this UZip object (when adding a file), a ZipEntry or null (when searching by string) or an array of ZipEntry (when searching by regex).
Arguments:
fn
: string| RegExpThe name of the file to add (if data is defined), the name of the file to find (if no data) or a regex to match files.
data
: string| ArrayBuffer| Uint8Array| UBMail.TubSendMailAttachKind.BufferThe file data, either raw or base64 encoded
o
: objectFile options
# generate (oopt: object) → string | Uint8Array | ArrayBuffer | UBMail.TubSendMailAttachKind.Buffer | Blob instance
Generate the zip. Zipped content can be prepared in-memory (as JSZip/PizZip did) or written directly into file (UZip feature) in case options.type='file'. File to write into is passed as option.filename.
Writing zip directly into file uses buffering io, so file content can be huge.
Return:
the zip file. If type='file' result is o.filename (a path to file)
Arguments:
o
: objectbase64
: boolean(deprecated, use type instead) true to generate base64
compression
='STORE': string"STORE" by default (no compression at all) or DEFLATE
type
='base64': stringValues are : string, base64, uint8array, arraybuffer, blob, file
filename
: stringif options.type='file' - sets a file name to create an archive
the options to generate the zip file
# load (data: string | ArrayBuffer | Uint8Array, optionsopt: object) instance
Read ZIP archive
differences from JSZip@2 / PizZip:
- if data is string, then this is a pathToFile, file content is NOT loaded into memory wholly, but only headers is loaded first. After access to file inside archive - only this file content is loaded into memory
Arguments:
data
: string| ArrayBuffer| Uint8Arraythe data to load. If string - this is a file name
options
: objectbase64
: booleanset to true if the data is base64 encoded, false for binary. More.
checkCRC32
: booleanset to true if the read data should be checked against its CRC32. More.
optimizedBinaryString
: booleanset to true if (and only if) the input is a string and has already been prepared with a 0xFF mask.
createFolders
: booleanset to true to create folders in the file path automatically. Leaving it false will result in only virtual folders (i.e. folders that merely represent part of the file path) being created. More.
decodeFileName
: functiondecode from UTF-8.the function to decode the file name / comment. https://stuk.github.io/jszip/documentation/api_jszip/load_async.html#decodefilename-option
the options for creating this objects
var zip = new UZip();
zip.load("UEsDBAoDAAAAAJxs8T...AAAAAA==", {base64: true});
# remove (fn: string) → UZip instance
Mark file or folder (recursively) to be removed from archive
Arguments:
fn
: string