Jszip: Simple unzip to directory

Created on 12 Aug 2014  路  2Comments  路  Source: Stuk/jszip

Is there a way to simply unzip all contents of a zipfile to a directory?

questiosupport

Most helpful comment

Shouldn't this be addressed by the lib?

All 2 comments

No, there's no such way.

You'd have to聽write your own code to聽do all聽of the聽following:

  • Pass /.*/ as聽regex to聽.file(regex) to聽get an聽array of聽ZIP聽entries.
  • In聽each of the entries (ZipObject instances), check .dir property:

    • If .dir is false, use .name property as聽a聽path (relative to聽your target directory) to聽create a聽target聽file and聽then use one of the ZipObject's getters to聽fetch that聽file's content and聽write聽it to聽the聽created file.

    • If dir is true, skip it. (The聽necessary directories should be created already if .name of a聽file contains subdirectories.)

Shouldn't this be addressed by the lib?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikeiasNS picture mikeiasNS  路  5Comments

bbirdiman picture bbirdiman  路  5Comments

dhruvin16 picture dhruvin16  路  4Comments

RUSHt picture RUSHt  路  5Comments

ryanakl picture ryanakl  路  4Comments