Giter Club home page Giter Club logo

jszip's Introduction

JSZip

A library for creating, reading and editing .zip files with JavaScript, with a lovely and simple API.

See https://stuk.github.io/jszip for all the documentation.

const zip = new JSZip();

zip.file("Hello.txt", "Hello World\n");

const img = zip.folder("images");
img.file("smile.gif", imgData, {base64: true});

zip.generateAsync({type:"blob"}).then(function(content) {
    // see FileSaver.js
    saveAs(content, "example.zip");
});

/*
Results in a zip containing
Hello.txt
images/
    smile.gif
*/

License

JSZip is dual-licensed. You may use it under the MIT license or the GPLv3 license. See LICENSE.markdown.

jszip's People

Contributors

3on avatar adm90 avatar calvinmetcalf avatar chalker avatar dduponchel avatar ddxdental avatar edi9999 avatar evilaliv3 avatar feugy avatar gztomas avatar isochronous avatar jsoref avatar majindageta avatar maxwellium avatar michaelaquilina avatar mithgol avatar mljsgto222 avatar mojoaxel avatar morfey13 avatar patrickjs avatar patricsteffen avatar peeja avatar sergio91pt avatar sheetjsdev avatar stevennyman avatar stuk avatar vcastro45 avatar vdoubleu avatar zackmfleischman avatar zakarynichols 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jszip's Issues

Can't load a zip file: lastIndexOf does not exist in class StreamReader

I'm trying to use jszip to read epub files (which are basically zip archives), but I face a problem with opening a file using new JSZip(data): it fails with error about non-existent lastIndexOf in class StreamReader. I found this class in jszip-load.js, and it actually does not contain this function.

Deflate compression error

i have found an error while i'm compressing a text with the deflate compression.

this is the code used:

var compressed = new JSZip().file("records.txt",JSON.stringify(packet)).generate({base64:false,compression:"DEFLATE"});

where the result of the JSON.stringify(packet) is:
{"RTS_1PG_SEC_DETAIL_REPONSE":"[["poid_sect_detail","tmp_activity",["07431370856073626","07431370856123482","07431370857111864"],"clgcode",[null],"data_agg",["10-06-2013 11:21:13","10-06-2013 11:22:03","10-06-2013 11:38:31"],"user_id","value"],[1359,0,0,0,743,-1],[1360,0,0,0,743,-1],[1938,0,0,0,743,-1],[2118,0,0,0,743,-1],[2119,0,0,0,743,-1],[2120,0,0,0,743,-1],[2121,0,0,0,743,-1],[1352,0,0,0,743,-1],[1353,0,0,0,743,-1],[1112,1,0,1,743,-1],[1113,1,0,1,743,-1],[1116,1,0,1,743,-1],[1117,1,0,1,743,-1],[1119,1,0,1,743,-1],[1120,1,0,1,743,-1],[1121,1,0,1,743,-1],[1114,1,0,1,743,-1],[1115,1,0,1,743,-1],[972,2,0,2,743,-1],[974,2,0,2,743,-1],[1941,2,0,2,743,-1],[978,2,0,2,743,-1],[979,2,0,2,743,-1],[980,2,0,2,743,-1],[981,2,0,2,743,-1],[975,2,0,2,743,-1],[976,2,0,2,743,-1]]","RTS_1PG_PRODUCT_REPONSE":"[["tmp_activity",["07431370856073626","07431370856123482","07431370857111864"],"clgcode",[null],"poid_product","stato_presenza","data_agg",["10-06-2013 11:21:13","10-06-2013 11:22:03","10-06-2013 11:38:31"],"user_id"],[0,0,2169,2,0,743],[0,0,2170,2,0,743],[0,0,2171,2,0,743],[0,0,2172,1,0,743],[0,0,2173,2,0,743],[0,0,2175,2,0,743],[0,0,2176,2,0,743],[0,0,3082,2,0,743],[0,0,2177,3,0,743],[0,0,3083,3,0,743],[0,0,3084,2,0,743],[1,0,2010,2,1,743],[1,0,2011,3,1,743],[1,0,2006,2,1,743],[1,0,2007,2,1,743],[1,0,2008,2,1,743],[1,0,2009,2,1,743],[2,0,1692,null,2,743],[2,0,1693,null,2,743],[2,0,1694,null,2,743],[2,0,1695,null,2,743],[2,0,1696,null,2,743],[2,0,1697,null,2,743],[2,0,1676,1,2,743],[2,0,1677,1,2,743],[2,0,1678,2,2,743],[2,0,1679,2,2,743],[2,0,1680,2,2,743],[2,0,1681,2,2,743],[2,0,1682,2,2,743],[2,0,1683,2,2,743],[2,0,1684,2,2,743],[2,0,1685,2,2,743],[2,0,1686,2,2,743],[2,0,1687,2,2,743],[2,0,1690,2,2,743],[2,0,1691,2,2,743],[2,0,1892,3,2,743]]","RTS_OCLG_LOCAL":"[["ClgCode_local","user_id",["CAMILLA.BORZILLO"],"clgcode_sync",[null],"CardCode",["10338420"],"Notes",[""],"Recontact","Closed",["N"],"CloseDate",[null],"ContactPer",[null],"Tel",[null],"Fax",[null],"CntctSbjct","AttendUser","CntctCode",[null],"UserSign","Action",["M"],"Details","CntctType","BeginTime","ENDTime",[null],"Priority",["1"],"endDate",["31-12-2013 00:00:00","31-07-2013 00:00:00"],"status","personal",["Y"],"inactive",["N"],"prevActvty","AtcEntry",[null],"U_CATEGORIA",[null],"U_insegna",[null],"U_tipologia",[null],"U_tipo",[null],"U_business",[null],"U_frequenza","U_categoria1pg","U_livcliente",[null],"U_id_categoria_ass",[null],"U_regione",[null],"U_canale_1pg",["Super 800-2500"],"U_fine_sellin",[null],"U_inizio_sellout",[null],"data_agg","Transfered",["N"],"U_KPI_OK",[null],"U_cm_cat",[null],"U_cm_ul",[null],"U_ul_facing",[null],"U_ul_sos",[null],"U_brandblock",[null],"U_ul_vaschette",[null],"U_ul_visibilita",[null],"U_display",[null],"U_esp_cat",[null],"U_extra_disp_perm",[null],"U_Notifica",["0"],"U_azione",[null],"U_ID_Mail",[null]],["07431370856073626",0,0,0,0,"10-06-2013 11:21:13",0,0,0,0,0,-1,743,0,743,0,"One pager Dressings 2013 SUD",4,1438,0,0,0,-3,0,0,76420,0,0,0,0,0,0,4,11,0,0,0,0,0,0,"10-06-2013 11:21:13",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],["07431370856123482",0,0,0,0,"10-06-2013 11:22:03",0,0,0,0,0,-1,743,0,743,0,"One Pager Hand Dish Wash",4,945,0,0,0,-3,0,0,76117,0,0,0,0,0,0,4,4,0,0,0,0,0,0,"10-06-2013 11:22:03",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],["07431370857111864",0,0,0,0,"10-06-2013 11:38:31",0,0,0,0,0,-1,743,0,743,0,"One Pager Hair SUD - SUPER 801 - 2500",4,1934,0,0,1,-3,0,0,35498,0,0,0,0,0,0,4,9,0,0,0,0,0,0,"10-06-2013 11:38:31",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]"}

The problem is the world Wash in position 3359
The deflate works if h is deleted or substitute with an other char, if the wolrd is swapped like "One Pager Hand Dish Wash" ---> "Wash One Pager Hand Dish"
or if at least 5 spaces are put beetween s and h

corrupted zip archive when adding files with base64: false, binary: true

I have binary data in a string from an ajax call. If I add it to a zip file the generated archive will be corrupted. This problem does not occur when setting binary to 'false' (but then of course, the unzipped file is corrupted)

Code looks like this:

        zip = new JSZip()

        $.ajax 
            url: url
            dataType: "text"
            beforeSend: (x) ->
                if x?.overrideMimeType
                    x.overrideMimeType 'text/plain; charset=x-user-defined'
            success: (data) -> 
                zip.file(filename, data, {base64: false, binary: true})

later:

        zipFileLink = "data:application/zip;base64," + zip.generate
            base64: true
            compression: 'STORE'

unzip fails on the resulting zip file with an error like:

$ unzip ~/Downloads/Unknown-8.zip
Archive: /Users/regular/Downloads/Unknown-8.zip
error [/Users/regular/Downloads/Unknown-8.zip]: missing 273 bytes in zipfile
(attempting to process anyway)
error [/Users/regular/Downloads/Unknown-8.zip]: attempt to seek before beginning of zipfile
(please check that you have transferred or created the zipfile in the
appropriate BINARY mode and that you have compiled UnZip properly)
(attempting to re-compensate)
creating: assets/
extracting: assets/cell_4_icon bad CRC 9d9641f6 (should be 0ed23482)
file #3: bad zipfile offset (local header sig): 924
(attempting to re-compensate)

DEFLATE failed

When this file is compressed with jszip-deflate, the generated zip file is broken. If not compressed, everything goes right.

Unable to create legit zip with binary files.

I just want an image from an xhr into a zip file. No matter what I do, the file is corrupted in the zip (in this case, it tries to extract as a cpgz file). Text works fine.

See the example. It should download a zip with an image of a kitten when the link is clicked:

https://github.com/benogle/jszip/blob/binary-example/examples/xhr-download-zip-file.html

What am I doing wrong? Is there a bug? I tried both the blob, arraybuffer, and old & 0xff stip method. Nothing works.

Accented characters in file names mangled.

Create an HTML file with the following content:

<html>
    <head>
        <!-- using rawgithub.com here, instead of raw.github.com -->
        <script src="https://rawgithub.com/Stuk/jszip/master/jszip.js"></script>
        <script src="https://rawgithub.com/eligrey/FileSaver.js/master/FileSaver.js"></script>
    </head>
    <body>
        <script>
            var zip = new JSZip();
            zip.file("ü", "The quick brown fox jumps over the lazy dog.");
            window.saveAs(zip.generate({type:"blob", compression:"STORE"}), "z.zip");
        </script>
    </body>
</html>

(conveniently reachable at http://tqft.net/misc/z.html), and unzip the resulting zip file. The filename comes out wrong (at least on OS X).

I see that the code does attempt to handle utf8 encoding file names, but it appears it's doing something wrong.

Version JSZip

I think the project would benefit from providing a notion of the versions. This will help those using the library to know, from quick glance, the stability or the compatibility of different commits. I think only good can come of this and it's a very small amount of pain to establish this versioning.

rawinflate.min.js.map and rawdeflate.min.js.map not in source code?

When loading my page and running JSZip I'm getting this error:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8000/Libs/rawinflate.min.js.map

and

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8000/Libs/rawdeflate.min.js.map

I can't find the file 'rawinflate.min.js.map' or 'rawdeflate.min.js.map' anywhere in the 'Stuk-jszip-v2.0.0-2-g7718693' download file. Is anyone else getting this error? Btw I'm running a nodejs server for local development, but I've uploaded it to my site and get the same error (its hosted by lunarpages if that helps). Also the error is appearing over and over again when I open the console.

Thanks for any help!

UNZIP Object error in IE9

I have the following piece of code:

$.ajax({
    url: "file.zip",
    beforeSend: function ( xhr ) {
        xhr.overrideMimeType("text/plain; charset=x-user-defined");
    }
})

.done(function ( data ) {
    var zip = new JSZip(data);
    ( ... )
});

The code work very well in Firefox and Chrome, but in IE9 at 'new JSZip(data)' I get the error:

End of stream reached (stream length = 251617, asked index = 251619). Corrupted zip ?

Kleyson Rios.

Jszip

Dear sir i am using your jszip.js for client side file compression
but when i do like this
var zip=new JSZip();
for (var i = 0, file; file = files[i]; ++i) {
try{
zip.add(file.name,file);
}catch (e) {
alert("Message: "+e);
}

}
There is no problem in zip. But when i open the zip contents the file does not contain any data.For example if i pass a word file it contains '[object File]' instead of actual data what i wrote in it
Please help me

Unzipping file results in *.cpgz file in place of contents

I'm using Node.js to zip up a directory using the node-zip wrapper for JSZip. The creation of my ZIP file works great, but when I try to unzip the file I get what appears to be another archive instead of the directory I was expecting.

You can check out my entire project here:
https://github.com/commadelimited/jsdownloader

The main work is being done in this file:
https://github.com/commadelimited/JSDownloader/blob/express-version/routes/download.js

But here's the relevant lines of code:

writeZip = function(dir,name) {
    var zip = new JSZip(),
        code = zip.folder(dir),
        output = zip.generate(),
        filename = ['jsd-',name,'.zip'].join('');

    fs.writeFileSync(baseDir + filename, output);
    console.log('creating ' + filename);
};

The values above are as follows:

dir = /tmp/jsd-<randomstring>/
name = <randomstring>

Here's the resulting ZIP file:
http://andymatthews.net/uploads/jsd-papuxetada.zip

Could I get some input as to what's going wrong?

Recursively remove files when remove()ing a directory

Currently only a single "file" is removed when calling remove(), even if doing remove("dir/").

Leads to broken Zips, and isn't what user's expect.

Will need to loop through all files to see if the paths match.

Binary data

Couldn't think of a better place to post this.

Your example has a note about getting this to work with binary data retrieved via XHR. You can get it to work using something like so:

xhr.open('GET', imageUrl); xhr.overrideMimeType('text/plain; charset=x-user-defined'); xhr.send(null);

Then process the data:

var data = xhr.responseText; var bytes = []; for (var i = 0; i < data.length; i++) { bytes.push(String.fromCharCode(data.charCodeAt(i) & 0xff)); }

Great little library btw, super useful.

NuGet package?

Any chance you could create a NuGet package for this project?

[Feature Request] Option to split zip into multiple parts with maximum size

The current URL lenght limit in chrome is 2097152 characters. So if you create a larger zip-file than that and try to download it, the chrome tab will crash.
However if you would be able to split the zip into multiple parts with a maximum character size of (2097152 - 28 (length of "data:application/zip;base64,") you could download all the parts using window.open

Comparable library to Downloadify

I'm experiencing problems when triggering the download of zip files larger than 20MB on IE10 and most likely lower versions of IE.

It works well when generating a zip that is smaller than 20MB, but it when I click the Downloadify button with a large file it just hangs and never prompts for a download.

ArrayBuffer values are deprecated in Blob Constructor

Chrome 23 produces a warning in the console upon loading jszip:
ArrayBuffer values are deprecated in Blob Constructor. Use ArrayBufferView instead.

Functions seem to work fine but may stop doing so in the future when support for ArrayBuffer values is dropped.

nodejs support?

Looking for a zip implementation in JavaScript, to be used within nodejs, I found this project. I just tested it locally and managed to create a valid zip file (turn off base64, write generated result to file). I'd like to know if there's interest in support nodejs, which would involve adding a package.json, exporting modules and publishing via npm.

I could help with that via PR, but wouldn't want to start that unless it'll get merged eventually.

Compression level 3 has bugs?

Inflating a string that was deflated using lvl3 compression will duplicate the last character. It will also, once in a blue moon, produce an output that can't be inflated (it crashes the .net deflatestream).

memory efficiency improvements

Using this library to read large zip files in browsers (2-80MB zipped, 15-300MB+ unzipped!) I unsurprisingly came across memory problems in various browsers (IE being worst of course, chrome best) and am thus trying to find ways to alleviate this

Looking at the original code, there seems to be a lot of string ops which seemed to cause some browsers to bloat their memory use, for instance I found I could replace this method in jszip-load.js:

findDataUntilDataDescriptorOld : function(reader) {
   var data = "",
       buffer = reader.readString(4),
       aByte;

   while(buffer !== JSZip.signature.DATA_DESCRIPTOR) {
       aByte = reader.readString(1);
       data += buffer.slice(0, 1);
       buffer = (buffer + aByte).slice(-4);
   }
   return data;

},

with the following method:

findDataUntilDataDescriptor : function(reader) {
 var data = "";

  var startIndex = reader.index;
  var endIndex = reader.stream.indexOf (JSZip.signature.DATA_DESCRIPTOR, startIndex);

  data = reader.readString (endIndex - startIndex);

  reader.readString (4); // this should chew the JSZip.signature.DATA_DESCRIPTOR bytes;

 return data;

},

I read slice on some browsers is a copying method, and one big slice operation (readString) seems to be preferable than 1000's of mini-slicing operations and concatenations.

PS I now think I've found a way to simply return the start index of the file data from this method and pass it into the zip inflate methods rather than a substring of the zip file to achieve the same result, but it involves some fairly unsubtle changes to a few methods.

Before I drop that in here, let me know if you think the above is at least an improvement or there's some reason I've gone wrong in my thinking somewhere (maybe someone's already done this?). I'm also looking at methods for only decompressing some of the files in a zip, and looking at changing/extending the inflate methods to conditionally ignore decompressed data (I'm working with large zipped csv datasets, so I'm trying to find ways to only read say the first and third columns, if I try and do this by reading the whole file into in memory the browser falls over, but I think I may have a chance if I discard the data as I'm decompressing it by counting field/line delimiters). Again this is all for my own problem so its use and generality for others is decreasing a bit.

PPS. This is a good library, it's the only javascript zip library I tested that did actually read the files in I needed!

PPPS. Sorry this post is very long.

Create JSZip object from .zip file.

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.

Special Chars ö, ü, ä, ß broken after unzipping from ArrayBuffer

Im unzipping an docx file, I can successfully read & manipulate it's contents and rezip it again into a docx file. Unfourtunaly all special characters (as described in subject) are broken immediatly after unzipping.

They're turned into fancy strings:
ö: ö
ü: ü
ä: ä
ß: Ã�

JSzip

Hi Stuk,
When i give location.href="data:application/zip;base64," + contnt; It gives an error in IE that insufficient data.Please help me.

How to zip a directory that contains pdf?

jszip works great when I was making zip from a list of text file. How can we handle pdf with jszip?

var zip = new require('node-zip')();
var fs = require("fs");

var files = fs.readdirSync('dummy');
for(var i=0; i< files.length; i++ ){
   var file_path = __dirname+'/dummy/'+files[i];
   var data = fs.readFileSync(file_path);
   zip.file(files[i], data);
};
var data = zip.generate({base64:false,compression:'DEFLATE'});
fs.writeFileSync('result.zip', data, 'binary'); 

Am I doing it wrong? Or how to do it?

NPM and JAM packages

I went a head and uploaded jszip to npm and jam as I needed it for a project and it looked like stuff was stalled here, @Stuk I'm more then happy to make you or anyone else you designate owners of the packages.

The version I uploaded is based off AMD based fork

using jszip to upload images

I am using html5 native filereader API to do drag and drop of images.

Let say 5 images.

Once the user is satisfied with her selection of 5 files, I want to upload these 5 images as a zip file.

Can I do that entirely with javascript and your jszip?

if so, can you afford me a simple example?

Thank you.

Error while trying to unzip a file compressed with jszip+Deflate

First of all, great work! Everything is working fine is I don't select any compression (STORE), but if I create the zip file using DEFLATE, the following error is coming up when I try to unzip the file:

Unable to expand "filename.zip" into "folder". (Error 2 - No such file or directory)

I'm using:
Mac OS X 10.8.4
Chrome 27.0.1453.110
jszip 1.0.1 (Stuk-jszip-v1.0.1-8-gcfdfe57.zip)

Considerations:

  • I've tried several apps to unzip the file, with the same result.
  • The zip file doesn't contain folders.
  • The compressed files are: png, docx and pdf.
  • Same issue with Firefox and Safari.

I attach two files:

"filename_store.zip" (which is working)
https://www.dropbox.com/s/l1k66pm6y2x84zb/filename_store.zip

and

"filename_deflate.zip" (which is NOT working).
https://www.dropbox.com/s/u2w2b643auk5wox/filename_deflate.zip

I would appreciate if you can take a look at this issue.

Many thanks,

Valnavjo

JSZip with Blob unexpected behaviour

Thats not an error, but when trying to use the results of generate it took me a while to figure out what's wrong. See http://stackoverflow.com/questions/13790949/downloading-generated-binary-content-contains-utf-8-encoded-chars-in-disk-file, read the comments to the accepted answer. So from that, I think it would be a good idea to be able to make generate return an Uint8Array on request. But more important would be to add a hint to the documentation about using Blob's (Maybe I missed it? Sorry then) But nevertheless, JSZip is a great thingy, thanks for it.

Issue loading unknown file types

Hi,

I'm trying to use your script to load a zip file being returned from an XMLHttpRequest which is directed to the GeoServer WPS engine.

The request returns a zip file which contains a GIS shapefile but in addition there is a small file as follows:

A shapefile downloaded from GeoServer will contain a .cst file. The .cst file contains the charset used to encode the dbf contents (this is not a standard file, but helps in reading back the shapefile in the case you encoded it with some special script such as Chinese, Arab, Hebrew for example).

This is causing an exception as follows:

Error: Corrupted zip : compression \x08\x00 unknown (inner file : trafficsites.cst)
[Break On This Error]

" unknown (inner file : " + this.fileName + ")");

Is there a way to avoid this issue? To be honest I'd be happy for it to skip that particular file altogether rather than fail.

Many thanks, the project seems really useful.

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.

Загрузка файла с правильным именем

var zip = new JSZip();
zip.add("Hello.txt", "Hello World\n");
img = zip.folder("images");
img.add("smile.gif", imgData, {base64: true});
content = zip.generate();
var a = document.createElement("a");
a.innerHTML = "download";
a.href = "data:application/zip;base64,"+content;
//a.download = "foobar.zip";
a.setAttribute("download", "foobar.zip");
document.body.appendChild(a);

failing

Hey there,

The library you are basing your Zip lib on doesn't work all of the time.
Which is unfortunate.

If you can get the following to work, I would really really really really really (and more reallys, really) be interested.

I'm going to try to paste an example of failure, not sure if this will work.

Well, that didn't work at all, lt me see if I can post it somewhere.

http://pastebin.com/UVU3vmxf

Loading ZIP in Android

Hi,

I am having a weird problem in Android.

I compress a string in my server and I read it on my device/browser. It is working fine using desktop browsers and iOS browser, but in Android... It crashes.

Using this code:

//Got from the server
var data = 'UEsDBAoAAAAAAHhkCUMAAAAAAAAAAAAAAAAEAAAAbnVsbFBLAQIUAAoAAAAAAHhkCUMAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAABudWxsUEsFBgAAAAABAAEAMgAAACIAAAAAAA=='; 

var zip = new JSZip(data, {base64: true});

In Android, shows this error:

Web Console: Uncaught Error: Corrupted zip or bug : unexpected signature (\x50\x4B\x05\x06\x00\x00\x00\x00\x01\x00\x01\x00\x32\x00\x00\x00\x22\x00\x00\x00\x00\x00, expected \x50\x4B\x05\x06)

FYI, I am using HTC One Mini running Android 4.2.2 and MioCare running Android 4.0.3

zip.file("amount.txt").asText() doesn't work

Hi,

I am trying to handle UTF8 data from an Ajax Request, but when I try to use zip.file("amount.txt").asText() as indicated in the manual, I get the following error message "unzip.files[jsonFile].asText is not a function"

Can anyone help me?

Thanks in advance for your help
Steve

Carriage return trimming

I was having an issue with the following code:

var text_block = '';

text_block += "Variable 1:"+var1+"\r\n";
text_block += "Variable 2:"+var2+"\r\n";
text_block += "Variable 3:"+var3;

var zip = new JSZip();
zip.file("variables.txt", text_block);

When I ran this script, it was creating the text file, but there were no new lines/carriage returns when opened in notepad. They showed when opened with wordpad, but I can't assume people are going to use that by default for a .txt file. Turns out, there's this code on lines 661-662:

utf8encode : function (string) {
     string = string.replace(/\r\n/g,"\n");

Simply commenting out 662 fixed my problem, but I can't imagine any use for it being there at all.

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.