Giter Club home page Giter Club logo

zip.js's People

Contributors

0f-0b avatar androidseb avatar blackaslight avatar bwbroersma avatar davispuh avatar dependabot[bot] avatar duanyao avatar floriszenz avatar gildas-lormeau avatar hexagon avatar josh- avatar kennygoff avatar mrmyhuang avatar nikodelarich avatar prepd-root avatar renanse avatar rob--w avatar savv avatar sbschorer avatar tim-we avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zip.js's Issues

Incomplete zip file when compress a big number of files. (+100)

Hi, I'm using a code similar to the example of multiple blob zipping.

function zipFiles(files, x, y, nFile, sdata) {
    zip.createWriter(new zip.BlobWriter("application/zip"), function(zipWriter) {
        var addIndex = 1;
    function nextFile() {
        if (addIndex < TableFiles[x][y].length) {
            zipWriter.add(files[TableFiles[x][y][addIndex]].name, new zip.BlobReader(files[DicomPatientsFiles[x][y][addIndex]]), function() {
            addIndex++;
            nextFile();
        }, function(current, total) {});
        } else {
            zipWriter.close(function(blob) {
                reader = new FileReader(); 
                reader.onload = function(evt) {
                    console.log('Test blob file ' + nFile + ': ' + evt.target.result) 
                }; 
                reader.readAsText(blob.slice(blob.size - 100,blob.size - 1)); // [1]
                Zipping -= 1;
            uploadZipBlob(nFile, blob, sdata[4]+'.zip', sdata);
              } );              
       }        
       }
       nextFile();
    }, onerror);
};

zipFiles(files, x, y, nFile, sdata);

The problem always happens even using the same groups of files. When the "Test Blob" log show data por that range [1], effectively, the zip is correct. In other cases, the blob look as incomplete and just contains a part (Each time with a different file size.) of the total zip file. The Blob.size always is correct. Maybe a problem with Chrome or with my code, but I can't find the final problem.

Error when using importHttpContent

"Uncaught Entry filename already exists."

See for yourself:

I don't know why this zip in particular (I've stripped it down from a much bigger file) but hopefully this gives something to work with?

Is there a group we can ask questions

I have an issue with creating a zip. I'm sure it's me and not the code. Having a google group or simliar would be useful for getting help.

Would you prefer stackoverflow ?

Chrome: File format is not recognized

It doesn't seem to recognize 0 (aka. store) compression method in any browser, but in Chrome everything is failing. I don't want to go into base64 encoding my data before hand to employ importData64URI as it is unnecessary extra cycles. You could perhaps add importArrayBuffer (as in xhr.responseType = 'arraybuffer'). Test case here: https://docs.google.com/open?id=0B5sQ3oZM4e3yZkdab0RsOVBRdktFUjBXMzg3YU5XZw

You can change image.def.zip for image.zip in xhr3

UTF-8 encoding preserves surrogate pairs

JavaScript use an UTF-16 style character encoding internally where characters beyond the basic multilingual plane are encoded as a surrogate pair consisting of a character in the range 0xD800 - 0xDBFF followed by one in the range 0xDC00 - 0xDFFF. In Unicode these are illegal code points, in UTF-8 such a pair must be joined into a single 4 byte sequence.

zip.js implement both an encoder that instead produce two 3 byte sequences, and a decoder that produce garbled output in case of 4 byte sequences.

Incorrect documentation

http://gildas-lormeau.github.com/zip.js/fs-api.html incorrectly lists the methods below:

FS.prototype.importHTTPContent(URL, useRangeHeader, onend[, onerror])
ZipDirectoryEntry.prototype.addHTTPContent(name, URL, size, useRangeHeader)
ZipDirectoryEntry.prototype.importHTTPContent(URL, useRangeHeader, onend[, onerror])

I believe all of these should be 'HTTP' -> 'Http'.

Command line usage

Would this be usable from the command line? Perhaps by itself or a wrapper script.

Windows has command line cscript.exe to process javascript.

how do i load a img from zip?

i'm followed the " reading sample "to open zip file and read a text file success! but i can't do it success with load a img file! could you help me? and if i do load zip file from XHR with my self , should i use any API to open the zip , i try to use the TextReader(XHR.responseText) , but the result isn't the same as HttpReader.

here is my code:

var reqeust=new XMLHttpRequest();
reqeust.onreadystatechange=onZipFileLoaded;
reqeust.onprogress = onZipFileLoadProgress;
reqeust.open("GET",zipFilePath);
reqeust.send();
zip.workerScriptsPath="js/";
var zipReader;
var zipEntries;
function onZipFileLoaded(){
    if(reqeust.readyState==4 && reqeust.status==200){
        zipReader=zip.createReader(new zip.HttpReader(zipFilePath),onZipFileOpened);
}else if(reqeust.readyState==4 && reqeust.status==404){
        //alert(reqeust.readyState+"没有找到相关的数据");
        setDocumentTitle("访问数据失败");
    }
}
function setDocumentTitle(str){
    document.title =str;
}
function onZipFileLoadProgress(event){
    if (event.lengthComputable) {
        setDocumentTitle( "已初始化..."+(Math.floor(event.loaded / event.total*100))+"%");
    }
}
function onZipFileOpened(reader){
    reader.getEntries(patseEntries);
}
function patseEntries(entries){//filename
    zipEntries=entries;
    getEntryByName(Request("code")+"/owcfg.data",new zip.TextWriter(),function(text){
                var obj= text.parseJSON();
                setDocumentTitle(obj.husbandName+"和"+obj.wifeName+"的婚礼");
            });

    getEntryByName(Request("code")+"/[email protected]",new zip.BlobWriter(),function(blob){
            //trace(blob);
            var reader = new FileReader();
            reader.onload = function(e){  
                var imgData = e.target.result;
                document.getElementById("logo").src=imgData;
            }  
            reader.readAsDataURL(blob);  
        });
}
function getEntryByName(filename,writer,callback){
    for(var i=0;i<zipEntries.length;i++){
        var entry=zipEntries[i];
        if(entry.filename==filename){

            entry.getData(writer, callback);

            break;
        }
    }
}
function trace(str){
    document.getElementById("content").innerText=str;
}

Zip Files Do Not Unzip on Mac OS

They unzip fine from the command line.

But when I double click to unzip in mac Finder, they give me an error message

"Unable to expand "Project (2).zip" into "Downloads"
(error 2 - No such file or directory)

I verified this on two machines.

Examples

Hi,

I Tryed to search for examples/documentations with File API and zip.js but I did not find a way to Unzip all the structure and files into Persistent File System. The big problem is how to keep the structure of folders and files inside.

Demo don't work in IE10

Demo Basic zip file creation don't work in IE10.
Download button erase zip content form field and download process never start.

Blob constructor vs. BlobBuilder

BlobBuilder and Blob.webkitSlice() have both been deprecated in Chrome. The code should be updated to use the Blob constructor and Blob.slice() instead.

Chrome: File format is not recognized

i am trying to read zip file in latest google chrome. , in it xhr request in not working (cross origin error. only http allowed ).
getting the error File format is not recognized when trying to call getEntries.

No examples in documentation

README is empty, and website/documentation doesn't give any example for how to actually use this. Would be great if the test*.js files were explained.

reading multiple files at the same time

there seems to be an issue with reading multiple files at the same time.
lets say i try to read 2 files out of an zip archive. one is 23 Bytes and another one has 42 Bytes.
If i first start to read file 1 and - before that is finished - start reading file 2 it just reads 23 byts instead of all 42. The "onload" callback is never called for file 2 because its never loaded completely.

Currently I have no example to show whats "wrong" but i could add one later if you want.

BTW: just testet it with the BlobReader, don't know if this happens in other readers, too.

Chrome crashes reading zip file...

I use de zip.js like...:

zip.createReader(new zip.BlobReader(datos), function(reader) {
reader.getEntries(function(entries) {
for(var i = 0; i < entries.length; i++) {
entries[i].getData(new zip.BlobWriter(), function(blob) {.....

In firefox I don't have a problem but in chrome the browser crashes.

There are 1000 files inside the zip...

It's a bug or do you have any sugestion??

getData() does not populate Blob.type

Reading a blob from a .zip does not populate the Blob's .type. When using the HTML5 Filesystem API to write files to the sandboxed filesystem, it's important that the mimetype is correct.

filentry.getData(new zip.BlobWriter(), function(blob) {
  //blob.type == ""
});

Getting Z_BUF_ERROR on valid/complete data

Hi there,

First of all thanks for a great library :)

I seem to have hit a bug. When feeding a particular buffer (498 bytes long) to Inflate.js, the append callback returns -1 instead of the uncompressed data.

I put together a little test case that exhibits the problem: [removed]

Digging a little bit into the code, it turns out the following condition ends up being true:

            if (nomoreinput && (err == Z_BUF_ERROR))
                return -1;

(from Inflater.append's main loop)

FWIW, the compressed buffer has been generated by .NET's DeflateStream class and not only can I read it just fine in .NET, Inflate.js does a great job of reading lots of other compressed buffers generated in the same way. So it seems this particular buffer triggers some bug inside Inflate.js (that or I messed up somewhere).

As a workaround, changing return -1; to break; in the above condition makes Inflate.js return the correct uncompressed data.

To me, it looks like the buffer has been properly inflated but the termination logic is wrong and expects more data instead?

importHttpContent is gone?

Hi,
I've just updated (after a loong time) the zipjs files in extensionizr.com
and when it didn't work I tried digging in, and all the code regarding using url of a zip as the import seems to be gone.
zip.HttpRangeReader, zip.HttpReader, importHttpContent
Is there another way of importing a zip file via url?
Am I missing something?

AE-1 and/or AE-2 AES encrypted file creation

I'm interested in adding support to create AES encrypted files to this library. Not sure if this was in your roadmap, but I've been taking a look at the specification, and without actually looking to the zip.js implementation in depth, it looks like this is doable. Do you see any pitfall, or do you have any tip on doing this?

Also, from what I understood, zip.js does not support generating the file in chunks, right? From what I understood, If I try to create a 4GB file, the file will be put in RAM/HDD.

Thanks.

i am using html5 filereader api for drag and drop images. how do i then use your zip.js to upload as zip file

I am using html5 native filereader api.

I have a div where my users drag and drop the images in.

the setup is similar to this example. http://robertnyman.com/html5/fileapi-upload/fileapi-upload.html

after the users are happy with the preview, i want to zip up all the images into a single zip file to be uploaded to my server.

the files are evt.dataTransfer.files which is a readonly property of the HTML5 FileReaderAPI see http://help.dottoro.com/ljslrhdh.php

I want to zip up all the files inside evt.dataTransfer.files and upload to the server when the user pressed submit button.

I have gone through your demos, but all of them are for downloads. Anything suitable for uploads and how do I zip?

I believe in your demo3, you iteratively traverse all the dataTransfer.files and then call importBlob on each one of them.

Is that the best way for me as well? I am merely implementing a kind of multi image uploader app.

Simple functionality needed

First of all, this project looks really cool.

But I can't use it, it depends on a number of too new browser features. All I need is to compress a string to a shorter string and uncompress it again later reliably.

It would be great if this project could separate the job of compressing from anything that requires features that are not implemented in all widespread browsers.

Problems with some special characters in file names

Hello!

When zipping files with special characters in their file names, some of these special characters are replaced by others in the resulting zip archive.

For example, "§" becomes "-º" and "ä" becomes "+ñ".
Do you know why that is and what I can do about it?

Thanks,
Richard

compressing a file of ~100MB gives incomplete zip file

Got an incomplete zip file of 100 bytes, when I tried to compress a ~100MB xml file via temporary storage in RAM.

It seems only zip header(PK~) / filename are there, not compressed date itself.

Didn't observe exception in browser console or demo page.

I can reproduce it by:

1. open http://gildas-lormeau.github.com/zip.js/demos/demo1.html  , with chromium 25.0.1364.172 (187217)
2. add the 100MB file when RAM is chosen for temp storage
3. wait till finish, and click "download".

By the way, a few tests

  • For ~50MB file, temporary storage at RAM still works
  • For ~500MB file, temporary storage at HDD still works

Any idea about the real threshold?

BlobBuilder is deprecated

In latest browser versions (Chrome v23) a message is showed on the console about BlobBuilder is deprecated in benefict of Blob constructor, that it's what finally got to the specification. This should be changed, since it have been around since several versions ago and BlobBuilder will be removed in the future.

BlobConstructor error in Safari 5.1

The current version of the script no longer works in Safari 5.1 on Windows or OSX.

TypeError: '[object BlobConstructor]' is not a constructor (evaluating 'new Blob')

Compressed Size Mismatch when opening zip with ICSharpCode.SharpZipLib

Is there a reason why the compressed size is not written into the common header? Looks like it's just the uncompressed size, line 802 in zip.js. I think this is giving me an error when opening a zip.js zip file in a C# zip library: "Compressed size mismatch between central header(847) and local header(0)".

how to read content of a file under a directory in zip package

I found that getData(new zip.TextWriter(), function(text){console.log(text)}} only read the file under root directory of the zip package. All other files under a directory throw an error message "error load resouce file" about inflate.js

is there any method to read them out?

Decompress a typed array.

Is there a way to decompress a typed array? After a file is read part of it is stored in a typed array. Portions of this typed array are gzip'ed. I would to input a typed array for decompression.

None of the tests run?

I just downloaded the entire repository and none of the "tests" run, I see nothing in any of the screens and in IE 9 I get the error:

Line: 210
Error: ArrayBuffer not supported

I'm very confused in that the tests are the only documentation and none of them run ie IE, Firefox or Chrome ...

zipWriter.add onend has not really ended?

Using Chrome 23.0.1271.64.
If I go to http://gildas-lormeau.github.com/zip.js/demos/demo1.html and click download twice, the second time it also tries to download but gets "0 B No File". This is not a big issue since you are only supposed to download these files once -- however, I see the same thing happen in my code under different circumstances.

In my own example, I see this same effect ("0 B No File") if I trigger getBlobURL immediately upon zipWriter.add onend. This can be solved in my case by waiting a few hundred milliseconds after onend before trying getBlobURL. My code is heavily based on demo1.html with the only real difference being that upon "click", "addFiles" is called and then "getBlobURL". Obviously, I'd rather know when the zip has completely finished writing etc. before doing anything else.

Thanks!

Documentation for Filesystem API needs updating

Fragment from https://github.com/gildas-lormeau/zip.js/blob/master/WebContent/zip-fs.js :

    ZipFileEntryProto.getText = function(onend, onprogress, checkCrc32, encoding) {
        this.getData(new TextWriter(encoding), onend, onprogress, checkCrc32);
    };
    ZipFileEntryProto.getBlob = function(mimeType, onend, onprogress, checkCrc32) {
        this.getData(new BlobWriter(mimeType), onend, onprogress, checkCrc32);
    };
    ZipFileEntryProto.getData64URI = function(mimeType, onend, onprogress, checkCrc32) {
        this.getData(new Data64URIWriter(mimeType), onend, onprogress, checkCrc32);
    };

While on the documentation page at http://gildas-lormeau.github.io/zip.js/fs-api.html :

ZipFileEntry.prototype.getText(callback[, checkCrc32])

...

ZipFileEntry.prototype.getBlob(mimeType, callback[, checkCrc32])

...

ZipFileEntry.prototype.getData64URI(mimeType, callback[, checkCrc32])

If you adhere to the documentation, you'll submit your checkCrc32 setting (usually a boolean) as the onprogress callback and get an unhelpful error (TypeError: onprogress is not a function).

ERR_READ in Firefox/Safari, but not Chrome/IE10?

So, I don't know if this is just me not knowing what I'm doing or if you even have interest in maintaining this project anymore, but I've recently been working on something where your library has come very much in handy - super props for that.

However, I ran into an odd issue - I've started testing in other browsers than Chrome, and IE10 works flawlessly - unfortunately, Safari and Firefox seem to silently fail when I try to read a zipped blob file. I can provide more information if needed, but I'm wondering if I'm the only person experiencing this.

Feature request: running Mustache or other transformations on added files

Let's say I develop some set of plugins, and for the download site, I want users to be able to enter their namespace, so the downloaded plugins are edited using Mustache to match that namespace value. This doesn't seem to be currently possible when using zip.js.

Would this be a good feature to add to zip.js? If not, any tips on how best to implement this for such projects?
Thanks!

Incorrect values sent to onprogress for getFileEntry

I have a zipfs into which I've imported a blob. I'm using getFileEntry to then extract the zip to an HTML5 filesystem inside a Chrome app. This all works fine.
The onprogress callback though, is getting 'index' (first argument) values that fluctuate (i.e. don't always get bigger), and aren't always smaller than 'max size' (second argument). Max-size is correct.

I think the fix is to change line 236 in zip-fs.js from:

onprogress(currentIndex + index, totalSize);

to just:

onprogress(currentIndex, totalSize);

but I might be misunderstanding what this is meant to be doing.

Can't find variable: FileReader

Hi,

zip.js is working fine in firefox but it thrws error in safari as Can't find variable:filereader.can u please help me by provding sample code.

Some comments for new zip.TextWriter('utf-8') in FireFox

I think, you must change TextWriter. If I call it like

obj.zip.ZipReader(new zip.TextWriter(),...)

with undefined type of encoding, it'll produce dedicated execution error in FireFox. with

obj.zip.ZipReader(new zip.TextWriter('utf-8'),...)

no error was happened. What do you think about

encodng = encoding || 'utf-8'?

Chrome crashes when to many calls to getBlob are done

If I call getBlob on too many files in the archive (> 50 files), Chrome crashes.

I use the following code :

var zipEntries = new zip.fs.FS();
...
for (var i=0; i<myFiles.length; i++)
{
var entry = zipEntries.find( myFiles[i] );
entry.getBlob(...);
}

When I use the debug console of Chrome, I can see that a web worker is called (created ?) each time I call getBlob.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.