Jszip: Zip a txt file, the size is not compressed

Created on 22 Mar 2017  路  4Comments  路  Source: Stuk/jszip

I tried to zip a text file, but the downloaded zip file doesn't compress the size.

Here is my code:

        var zip1 = new JSZip();
        zip1.file("test.txt", "a very long text here");

        zip1.generateAsync({type:"blob"})
        .then(function(content) {
            saveAs(content, "test.zip");
        });

Could you please tell me what went wrong?

questiosupport

Most helpful comment

Use the compression option:

zip1.generateAsync({
    type: "blob",
    compression: "DEFLATE"
}).then(...)

All 4 comments

Use the compression option:

zip1.generateAsync({
    type: "blob",
    compression: "DEFLATE"
}).then(...)

Thanks, it works.

Cool !

@dduponchel
It is not working.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dhruvin16 picture dhruvin16  路  4Comments

sethdorris picture sethdorris  路  4Comments

carloscarcamo picture carloscarcamo  路  5Comments

v1nce picture v1nce  路  3Comments

Lsaes picture Lsaes  路  5Comments