Jszip: Issue with asUint8Array in jsZip 3.0

Created on 27 Jul 2017  路  1Comment  路  Source: Stuk/jszip

I tried to use asUnit8Array() method in jsZip 3.0, I received the error "Error: This method has been removed in JSZip 3.0, please check the upgrade guide." but unfortunately there is not much info on the upgrade document.

I am working on tizen applications, and trying to unzip a file in memory and save back the unzipped content (several files) into tizen filesystem.

is there any alternative way to read the unzipped content and convert them to blob object to save them into file system?

questiosupport

Most helpful comment

The upgrade guide give the following example:

// 2.x
zip.file("test.txt").asText();
// 3.x
zip.file("test.txt").async("string")
.then(function (content) {
    // use content
});

The method asUnit8Array follows the same migration path as asText:

// 2.x
zip.file("data.bin").asUnit8Array();
// 3.x
zip.file("data.bin").async("uint8array")
.then(function (content) {
    // use content
});

If you whish to get a Blob object, you can directly use .async("blob") with JSZip v3.

>All comments

The upgrade guide give the following example:

// 2.x
zip.file("test.txt").asText();
// 3.x
zip.file("test.txt").async("string")
.then(function (content) {
    // use content
});

The method asUnit8Array follows the same migration path as asText:

// 2.x
zip.file("data.bin").asUnit8Array();
// 3.x
zip.file("data.bin").async("uint8array")
.then(function (content) {
    // use content
});

If you whish to get a Blob object, you can directly use .async("blob") with JSZip v3.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Lsaes picture Lsaes  路  5Comments

dhruvin16 picture dhruvin16  路  4Comments

v1nce picture v1nce  路  3Comments

despairblue picture despairblue  路  7Comments

jrfnl picture jrfnl  路  3Comments