jszip 解压压缩包_JSZip解压缩错误

  • Post author:
  • Post category:其他

bd96500e110b49cbb3cd949968f18be7.png

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.

解决方案

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)


版权声明:本文为weixin_29958955原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。