-
-
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
Create JSZip object from .zip file. #7
Comments
I personally like the idea :) |
currently we have this constructor:
i propose the change:
It sniffs what the string is (looks for magic number or if it is one of the supported compression methods or something), and if it detects zipped data, it reads the compression method from the file and creates the JSZip object. Else it creates an empty JSZip object with the specified or default compression method. also currently we have these “public” methods:
i love this api, so i’d like to keep most of it. my proposed change is the following: merge
the file options would maybe contain a “force replacement” option. apart from that we don’t need much, except maybe a shortcut for |
I don't think trying to auto-detect the input is a good idea (same type (string) for compression method and data string).
The rest of your proposition sounds good to me ! |
you are of course right about the autodetection would work nicely, though. we’d just have to sniff the string. |
These are all absolutely great ideas, and I love the direction going on here. If anyone fancies hacking along these lines I will happily welcome the changes. I'm going to see if I can get some spare time this week to start bringing things up to date. |
I should finish the code/doc/tests for the new API this week end :) |
awesome! |
You can see the updated doc at http://dduponchel.github.com/jszip/ and the code on my branch |
The ajax code has been tested in : - IE 6 / 7 / 8 / 9 - the lastest firefox - firefox 3.6 - the lastest opera - the lastest chromium - the lastest safari The tests pass in all those browsers (except in IE 9 : the utf8 test was broken, I didn't fixed it).
Cheers! I'm in the middle of moving house/country at the moment, so it will take me a while to get a moment look at the code, sorry! |
Zip64 are generated for big files (> 4GiB, not really useful in a browser) and when a stream is compressed (the zip utility doesn't know the size, and uses zip64 for the worst case scenario). Two other changes : - The parser now read things backward (end of central dir, central dir, local files). Reading the file backward seems odd, but the zip format was designed to be read like that (and I have less troubles doing so). - I also enforced the Stuk's coding style (to be coherent with the other files).
hi, i have some problems with it. i tested it with jquery’s ajax function via python’s SimpleHTTPServer (to get around possible permission issues with local files). i used the following code: $.ajax({
url: "packs/johnsmith_v8.4.zip",
dataType: "text",
success: function(data){
var testZip = new JSZip(data);
console.log(testZip.file("terrain.png"));
}
}); and this zip file (saved locally) i get the error
but zipinfo -v says:
what cuts the stream? is it some kind of encoding issue? PS: i tried with some more .zips, but to no avail. |
Hi, That's a known issue : the browser tries to parse the ajax response as text and break it (issue #6). The solution for firefox/chrome/opera is to use The easiest way to test in IE might be to add a test case in test/index.html : the zip files are now (on my branch develop) loaded via ajax calls. I should add a note in the documentation as the issue is not obvious ! |
sorry for not looking into other issues blush. thanks to you it works fine now: $.ajaxSetup({
mimeType: "text/plain; charset=x-user-defined",
error: function(req, status, error) { console.error(error); }
}); |
Now implemented thanks to the above pull request. |
This stackoverflow answer links to a javascript class the does the reverse: Opening zip files and extracting files from it for further use.
It would be great to have a two-way zipfile object that can be created from a file, modified and downloaded as a file.
PS: the fix would answer my question here.
The text was updated successfully, but these errors were encountered: