-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to unzip archives created not by JSZip #250
Comments
How do you get the content of the zip file ? An ajax request in a browser ? |
No, it is not an ajax request in a browser. It is non-browser script engine in client application. Looks like the mentioned exception happens if there are non-text files in zip (e.g. png): One more issue. If there is only text file packed by other tool, zip is loaded but the list of files in JSZip object is empty: If the same text file is packed by JSZip, it is loaded correctly and JSZip files shows correct list: Here is how I get content of zip: var ZIP = new JSZip(); var content = objBinaryFile.ReadText(); // content for JSZip |
I tested the three zip files on my machine with JSZip (loaded with nodejs REPL) and
Same result with other tools. I don't know how to test this code on my side but I strongly suspect that the ADODB.Stream doesn't give you the exact binary content. The Read method looks promising but from this question on StackOverflow, setting the type parameter to 2 (adTypeText) is ok... Could you test:
I never used ADODB.Stream so these are guesses based on what I saw on the internet. |
Strange... Btw, ZipOK.zip is also can not be opened by other tools in my case. They do not recognize the file as zip archive. But JSZip is still can handle it oppositely to you... Concerning the ADODB.Stream:
|
So, I did some more tryings...
It looks for me like problem with charsets... |
Ideally, you shouldn't have any charset issue as you handle binary data. A charset is only useful when you transform text to and from binary data, that's why the JSZip doesn't know how to handle a Variant, but you could try to convert it to an array of integers (<= 255). That should be a simple loop to iterate and copy all values in an array (but I can't find any example actually using a Variant). |
I found the tricky way to convert this variant to a normal JS array where each item is integer <= 255... But when I try to load it with |
As long as pako supports regular JS arrays may be it make sense to support it in JSZip. It would add there one more usecase for such specific applications. |
In Stuk#250 case, we don't have fancy Uint8Array but we have a unsupported binary format. An array of bytes (numbers between 0 and 255) is the lowest common denominator. A binary string would awkward to build here and building it reliably can be tricky (without filling the stack or taking too much time/memory). This commit adds the missing `arrayReader` needed here.
Sorry, I forgot that the fallback was the Uint8ArrayReader. I tested the code in nodejs REPL... which supports Uint8Array.
We already use pako's support of arrays on platforms that don't support Uint8Arrays. We don't support arrays in the Could you check if it works with this branch (I built the dist files here) ? Out of curiosity, how do you read a Variant object ? |
Thanks, I will check it tomorrow and give you feedback then.
So, I assume if there is Array of Byte Variant received from somewhere it can be written into binary Stream and then converted in the similar way into array. |
Thank you for support! It works fine now.
I have the same result now. |
Cool ! I'll create a pull request with this fix. For the variant transformation, I though it would be something like var variant = binstream.Read();
var result = new Array(variant.Length);
for (var i = 0; i < variant.Length; i++) {
result[i] = variant[i]; // or getByte(i) ? byteAt(i) ? I don't know how to get values
}
new JSZip(result); I was wrong :) |
Released in v2.6.0. |
Hi. In my case JSZip unable to unpack zip created not by JSZip (e.g. by native windows zipper or by 7z with deflate). Exception is "End of data reached (data length = 4042, asked index = 4168). Corrupted zip ?" What can be wrong? Thanks in advance...
The text was updated successfully, but these errors were encountered: