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!

Published by

lucamezzalira

I’m the VP of Architecture at DAZN with more than 15 years of experience, a Google Developer Expert on Web Technologies and the London Javascript community Manager I had the chance to work on cutting-edge projects for mobile, desktop, web, TVs, set top boxes and embedded devices. I am currently managing DAZN, a sports video platform based on the cloud with millions of users that are watching live and on-demand contents. I'm the author of Front-End Reactive Architectures published by APress: https://goo.gl/ywAmsx I think the best way to use any programming language is mastering their models, that’s why I spent a lot of time studying and researching on topics like OOP, Functional and Reactive programming. In my spare time, I wrote for national and international technical magazines and editors, I'm also a technical reviewer for APress, Packt Publishing, Pragmatic Bookshelf and O'Reilly. I was speaker at: O'Reilly media webinars, O'Reilly Software Architecture (San Francisco & London), O'Reilly Fluent (San Jose), O'Reilly Oscon (London), Google Developers Summit (Krakow), Google DevFest (London), Frontend Devs Love (Amsterdam), Voxxed Days (Belgrad & Bristol), JeffConf (Milan), International Javascript Conference (Munich & London), JS Poland (Warsaw), Code Europe (Wroclaw), JSDay (Verona), CybercomDev (Łódź), Jazoon Conference (Bern), JDays (Göteborg), Codemotion (Milan), FullStack Conference (London), React London UG (London), Scrum Gathering (Prague), Agile Cymru (Cardiff), Scotch on the rocks (Edinburgh & London), 360Max (San Francisco), PyCon (Florence), Lean Kanban Conference (London), Adobe Creative Suite CS 5.5 - Launch event (Milan), Mobile World Congress (Barcelona)

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s