Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zipping files with javascript - corrupt archive

I'm trying to use JSZip to zip some text and then open it with 7Zip. The problem is, the archive is apparently corrupted at some point. I can't open it. I'm guessing it's not created correctly, possibly because I'm not using the correct encoding, but there could also be a slight chance that it's happening during transfer from my Android device (this is a Phonegap project) to my PC (I use adb to transfer the archive).

My code is:

var zip = new JSZip();
zip.add("hi.txt", "Hello World");
var content = zip.generate(true); // true == get raw byte string
writer.write(content);

Where writer is a Phonegap FileWriter object.

Any ideas?

like image 481
Johnny Avatar asked Jan 05 '12 13:01

Johnny


1 Answers

It is currently impossible to write binary data with Phonegap's FileWriter, as stated here by a PhoneGap guy.

like image 194
copy Avatar answered Oct 30 '22 07:10

copy