This repository has been archived by the owner on Aug 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
class util.Zip
Ayhan Rashidov edited this page Nov 22, 2021
·
1 revision
Class for manipulation of zip archives. It provides functionality for compressing, uncompressing, removal of entries and zip encryption.
- SAP Help
https://help.sap.com/doc/3de842783af24336b6305a3c0223a369/2.0.03/en-US/$.util.Zip.html
- Module
- 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 |
- Coverage
Members | Type | Description | Status |
---|---|---|---|
metadata | object | Contains meta information about the current zip object. | ❌ |
password | string | 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. | ❌ |
Methods | Return Type | Description | Status |
---|---|---|---|
asArrayBuffer() | byte array | Returns the zip object as byte array. | ✅ |
- Issues
- Unit Tests
- Integration Tests ❌
✅ - Feature implemented and working as supposed.
❌ - Feature not implemented yet.