Stuk / jszip

Create, read and edit .zip files with Javascript
https://stuk.github.io/jszip/
Other
9.78k stars 1.3k forks source link

End of data - corrupted zip ? #714

Open frontBOI opened 4 years ago

frontBOI commented 4 years ago

Hi everybody,

I am getting a compressed JSON file from a WebService and trying to decompress it using JSZip.

Compressed response

Here is the compressed response (which is a valid zip file, downloadable and extractable): PKz�<Q5416208540718863381.dat���j�0E� ���M�f$�F��R��& �Җ6ݗ�_9첮Ӌ�PZ�%_�<:�+����������y�ﻻ�c��.��?ޏÅ^��u��z����[���_]��:<�Ӳ����rhxZ�Z?�:} !�J�bQ}|V�xx;�oߏ�����>���ׯ���>��_����c�{��=^k��cw�x���Z�B�9�Ƭ�Tc�T-9O���@�U*MQE Ixߴ�FD�:�6� n�4� �ox��}Nq��<�+j�)b�"!f��J�S �;sf F�&J[� $9�&�@�l�� ���h����M$&D!���"�D�)�bQ�D^E��� D��*����+ƣ���^���m�bU�f�)bL2��bHRnaD*�V΃�F^�X]d��#��3W�"D�*kqq� FR��A 4��l0����o!s� �+��9V��t�����B�+�U�A?h�W�:����ACX�5��~�$�0;����Q%�� b��4₂�@�ĸC,f4������=���f,��׉ &���������-��xs3}�1�p5�ڇ:7���Fv��1όt}͞뼊�k�����}�2����RepC>z� =��w�0� Ӽ%\*��B1z�؆X�eKu�m�#=bl{l8� +cfQL�m�Re�l�Ȟ��9bnv�g�W�� c[Yyft�*z�����t�G����yK���n�0F��l��ĻN��w�p�:��x���ŻN� �u2����a�:�y��9�PK�M \��(PKz�<Q�M \��(5416208540718863381.datPKE<

Decompression code

And here is my code to decompress it (content contains the compressed text I posted before): `

  async decodeZIPFile (content) {
        return new Promise((resolve, reject) => {
          const JSZip = require('jszip')
          const zip = new JSZip()

          zip.loadAsync(content).then(unzipped => {
            resolve(unzipped)
          })
        })
      },

`

My problem

Unfortunately, this gives me the following error: Uncaught (in promise) Error: End of data reached (data length = 818, asked index = 819). Corrupted zip ?

What did I do wrong ?

jawn-ha commented 2 years ago

same problem? Did you solved?

ADCrouch commented 1 year ago

Same problem, did anyone find a solution?

Ebaq commented 1 week ago

I'm probably late but hope thats can help to someone else. I had the same error and it occurs due to your data fetching method. I fetch data with axios and the solution was to set responseType: 'blob' in axios instance. Then you're simply can make new Blob from response and unzip it with jszip