Skip to content

$.util.Zip

$.util.Zip is a class for manipulation of zip archives. It provides functionality for compressing, uncompressing, removal of entries and zip encryption.

Overview

Sample Usage

Create a new zip object.

// Create a new zip object
var zip = new $.util.Zip();
// Set content to the zip object
zip['xsk.txt'] = 'This is XSK';

// Download the zip file
$.response.status = $.net.http.OK;
$.response.contentType = 'application/zip';
$.response.headers.set('Content-Disposition', 'attachment; filename = test.zip');
$.response.setBody(zip.asArrayBuffer());
Create a zip object from byte array source.

// Zip byte array source
var source = [123, 34, 120, 115, 107, 46, 116, 120, 116, 34, 58, 34, 84, 104, 105, 115, 32, 105, 115, 32, 88, 83, 75, 34, 125];

var zip = new $.util.Zip({
    source: source
});

for (var entry in zip) {
    // Loop through zip entries and modify if needed
    if (entry === 'xsk.txt') {
        zip[entry] = 'XSK is great'
    }
}

// Download the zip file
$.response.status = $.net.http.OK;
$.response.contentType = 'application/zip';
$.response.headers.set('Content-Disposition', 'attachment; filename = test.zip');
$.response.setBody(zip.asArrayBuffer());

Constructors

new $.util.Zip(config)

Parameters

Zip object

Name Description Type
config Object containing new zip configuration parameters. object

config object

Name Description Type
source Specifies the source for the compressed content. If no source is specified, an empty Zip object is created. byte array / $.db.ResultSet / $.web.Body
index If the first argument is of type ResultSet, the number specifies the index of a Blob column and is mandatory. number
settings Used to specify zip options. object

settings object

Name Description Type
password The password is mandatory when creating a zip object from an existing encrypted archive. string
maxUncompressedSizeInBytes A global restriction applies to the amount of data that can be uncompressed number

Properties

Name Description Type
metadata Contains meta information about the current zip object. object
password Setting a value to this property changes the password used for encryption of the zip object. Assigning an empty string disables encryption. Accessing this property will return undefined. string

Functions

Function Description Returns
asArrayBuffer() Returns the zip archive as byte array byte array