Originally written for eImagine Technology Group and posted at http://thinketg.com/zip-js-exactly-what-it-sounds-like-awesome
Transferring data back and forth between a web service and a mobile application can be a real chore at times. For textual data, XML and JSON representations provide fast and highly-debuggable encapsulations of the data, but binary data continues to be a real pain at times; you must make choices on whether the data will be downloaded using file requests, present it as binary streams, encode it using Base64 and so on. It is with that in mind I share a brief story and a cool script that might help you out.
On a recent project I was faced with finding a clean method for taking whole directories of binary files (images, text, etc) and packaging it in such a way that it could be efficiently synchornized to a client mobile device while using as little bandwidth as possible. Once on the client device, the files would then need to be cached so as to enable offline/disconnected operation - a solid move for any mobile application since you can never guarantee connectivity or, at a minimum, the service level.
While kicking around ideas for this, I realized that if I were doing this in a single instance for my own purposes, I would have asked the person on the other end to "zip up" the files into a zip archive and send me the file. Perhaps, as an alternative, they could drop it out on a server somehwere for me to grab whenever I wanted. This would compress the contents of the package (the files) and maintain the directory structure so I would replicate the intended layout when I expanded the package.
The documentation (http://gildas-lormeau.github.io/zip.js/) is rather limited, but a little playing around mixed with the sparse examples will lead you in the right direction. Within a few minutes I was able to take a test zip file and pull it from my dev server and process it into the isolated storage, reconstituting it just as it should be. This presents a great way to push file deltas of overarching applications to clients and keep everyone on the same page.
Where To Get It
If you are comfortable with GitHub (or at least the Git system in general), clone the repository down to your local computer from https://github.com/gildas-lormeau/zip.js.git. If, however, you would rather just download the zip archive (ah, the relevance!) then you can grab it at http://github.com/gildas-lormeau/zip.js/zipball/master. Don't forget to check out the aforementioned documentation (or you will be really lost).
As always, feel free to hit me up with any specific questions as I am happy to help out!
- Firecracker, father, friend. Honorable, humorist, heathen. Performer, programmer, producer. Seeking, social, sarcastic. Loyal, logical, lasting. Bold, belying, benevolent. Gamer, genuine, grinning. Reader, redeeming, ridiculous.On and off blogger, film producer, and programmer. Keurig addict. Frequent moviegoer.