Working with zip files and Flash Platform

In our last Flash / AIR project we are working with tons of automations to create files, save them on computer, download files from the web and so on.

A library that I think could be interesting not only for us but also for other people that will work with zip files is FZIP from codeazur.

I saw it a couple of years ago and finally I used it, I think it’s so cool for your desktop or web projects based on Flex, Flash or AIR.
Working with FZIP is so easy, if you want to add a file into a new zip file you only write:

var zip:FZip = new FZip(); zip.addFile(f.name, f.data); //f is a File object instance

You can also set a particular position for your file with addFileAt method, remove a file, read each file and working with it without using any different language; all with Actionscript 3!

When you are ready to create your zip file you can save it with FileStream object like this:

var ba:ByteArray = new ByteArray(); zip.serialize(ba) ba.position = 0; var finalZIP:File = File.desktopDirectory.resolvePath("AIRZIPPER.zip"); var fs:FileStream = new FileStream(); fs.open(finalZIP, FileMode.WRITE); fs.writeBytes(ba); fs.close();
So easy, isn’t it?!
One of the main thing that could be interesting to know about FZIP is that library doesn’t read zip file with data descriptor like you can read on official website in Limitations paragraph:
FZip generally can’t read ZIPs that make use of Data Descriptors. Examples of such ZIPs are those created by the Mac OS X Archiver utility, SWCs, JARs, etc.
So to solve this problem I made a simple AIR application that zip your files (only files for now but soon I also work with folders and subfolders) and give a perfect zip file without any data descriptor, so you can use to work with FZIP lib.
You can download it for free from this link (I think they are on dedicated servers), I hope that you enjoy it and if you have any requests feel free to ask me via email or adding a comment to this post!
UPDATE
I’ve just received a mail from Claus of codeazur that gives me a new repository for FZIP where they solved data descriptor issue; thank you Claus!
Advertisements

3 thoughts on “Working with zip files and Flash Platform

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s