2

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.

kaytrance
  • 2,657
  • 4
  • 30
  • 49

2 Answers2

4

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)
David Duponchel
  • 3,959
  • 3
  • 28
  • 36
  • Thank you for your contribution. 8 years in and your comment has saved me hours of finding the resolution to this issue of loading base64 file. :) – DVA Nov 28 '22 at 09:50
0

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.