kaytrance
kaytrance

Reputation: 2757

JSZip unzipping error

Trying to handle with JSZip library.

I am having an issue to unzip a file. Here's a plunker demo. As you can see I can successfully zip a content, but when I try to unzip a zipped content I get an error (can be seen in console):

Uncaught Error: Corrupted zip : can't find end of central directory 

Any ideas why this happens?

In any case, here's what I am trying to achieve: I have an textarea on my page. Upon click I want to zip textarea content and send zipped data to server. Another call must be able to receive a zipped data, unzip it and replace textarea text with unzipped one. Everything works ok, except unzipping problem.

Upvotes: 2

Views: 8066

Answers (2)

Kapil Bhagchandani
Kapil Bhagchandani

Reputation: 493

As answered by David has resolved my problem on my local workstation running Windows 10 OS. However it is failed on the Server running RHEL OS.

I have to fix it by switching to yauzl package for unzipping. It is recommended as mention on package's official repository, with specified merge pull 383.

Upvotes: 0

David Duponchel
David Duponchel

Reputation: 4069

The generateAsync() method defaults to a base64 output but the loadAsync() method only see a string. You have two solutions :

  • change the generated format with `generateAsync({type:"uint8array"}) (see here)
  • or tell the load method that you are loading base64 content : loadAsync(data,{base64:true}) (see here)

Upvotes: 4

Related Questions