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 (fnstring | RegExp, dataoptstring | ArrayBuffer | Uint8Array | UBMail.TubSendMailAttachKind.Buffer, ooptobject) → 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| RegExp

    The 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.Buffer

    The file data, either raw or base64 encoded

  • o: object
    • base64boolean

      set to true if the data is base64 encoded string

    • isFilenameboolean

      UZIp specific - set to true if data is a path to file

    • date=Date.now()Date

      the last modification date

    • dirboolean

      Set to true if this is a directory and content should be ignored

    File options

# generate (ooptobject) → 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: object
    • base64boolean

      (deprecated, use type instead) true to generate base64

    • compression='STORE'string

      "STORE" by default (no compression at all) or DEFLATE

    • type='base64'string

      Values are : string, base64, uint8array, arraybuffer, blob, file

    • filenamestring

      if options.type='file' - sets a file name to create an archive

    the options to generate the zip file

# load (datastring | ArrayBuffer | Uint8Array, optionsoptobject) 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| Uint8Array

    the data to load. If string - this is a file name

  • options: object
    • base64boolean

      set to true if the data is base64 encoded, false for binary. More.

    • checkCRC32boolean

      set to true if the read data should be checked against its CRC32. More.

    • optimizedBinaryStringboolean

      set to true if (and only if) the input is a string and has already been prepared with a 0xFF mask.

    • createFoldersboolean

      set 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.

    • decodeFileNamefunction

      decode 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 (fnstring) → UZip instance

Mark file or folder (recursively) to be removed from archive

Arguments: