ActionScript GZIP compression library
This is an ActionScript library for encoding (compressing and uncompressing) files using the GZIP compressed file format. The source code for the ActionScript GZIP encoding library is hosted on Google Code; the code is available under the MIT license.
Note: version .2 and previous were licensed under the Mozilla Public License, v. 1.1.
Where it’s been used:
- This project is incorporated into an article I wrote for the Adobe Developer Center titled “Compressing files and data.” In that article I explain some of the background concepts around compression formats, and the article also includes a simple app that provides a UI for compressing and decompressing files that wraps this library.
- Danny Patterson uses the library to decompress GZIP-encoded data (SOAP web service calls) that are sent compressed from a web server, as he describes in his article “GZIP-Encoded HTTP Response in Adobe AIR.”
- Mark Lynch used the library, together with Anirudh’s code (described below) to create a drop-in GZIP-supporting replacement for the Flex HTTPService component that “does the right thing” and detects whether the content is GZIP encoded, decoding it if it is. This was on my list of planned future work for this project, so I’m glad he saved me the trouble!
- Anirudh Sasikumar wrote an extension of the Flex HTTP Service that provides support for gzipped HTTP responses, (in many ways a simplification of Danny’s work) as he describes in his post “Extending the Flex HTTP Service to Support Binary Data.”
You can leave a comment, or trackback from your own site.
24 Comments so far
Add your comment
Comment notes
Please keep comments on topic. Comments that are inappropriate or offensive will be edited or removed.
Paragraphs and line breaks are automatically converted to HTML, and quotation marks are converted to “smart” quotes.
The following XHTML tags can be used: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> . All others will be removed.
February 22nd, 2008 at 9:26 pm
Danny Patterson is reported to have said:
March 19th, 2009 at 10:37 am
Lynch Consulting Blog is reported to have said:
October 1st, 2009 at 4:00 pm
Yahoo! Developer Network Blog is reported to have said:
February 25th, 2008 at 1:56 am
Adobe - Developer Center : Compressing files and data is reported to have said:
June 20th, 2008 at 5:41 pm
Extending the Flex HTTP Service to Support Binary Data is reported to have said:
July 17th, 2008 at 1:18 pm
Alex is reported to have said:
Hi Paul,
I was pretty excited to find your GZIP library and was going to use it in my project. But then I discovered that it doesn’t work with Flex. Flex’s implementation of ByteArray.compress() is different than AIR’s and supports only default zlib compression. Any idea why are they different? Will Flex ever support gzip?
Thanks,
Alex
July 17th, 2008 at 2:46 pm
Paul is reported to have said:
@Alex:
Just to clarify, the library does work with Flex (I’ve only ever used it with Flex) as long as your Flex app runs in AIR. However, the library doesn’t work in Flash Player 9, so it doesn’t work in a Flex app that runs in the browser (or a non-Flex app that runs in the browser, for that matter).
The additional functionality (compression using the Deflate algorithm rather than zlib) was added in AIR — as you’ve noted, Flash Player only supports zlib.
The good news is that the functionality that was added in AIR has been rolled back into Flash Player for the next release (Flash Player “Astro”), which is currently available as a public beta. I haven’t updated the library to support that new functionality, obviously, but I plan to do so soon.
January 14th, 2009 at 11:19 pm
はてなブックマーク - FZip - codeazur brasil lab is reported to have said:
February 18th, 2009 at 12:30 am
akhil is reported to have said:
this library is working with desktop AIR application. But i want to use this library in web application flex. how can i do this
thank you
February 18th, 2009 at 1:31 pm
Paul is reported to have said:
@akhil:
Others have also commented on this, above. As I replied, it is theoretically possible to use the library in a Flash Player (browser) application now that the raw DEFLATE compression is supported in Flash Player. However, the refactoring work to support it turned out to be more complex than I thought so I haven’t had a chance to finish it up.
Obviously there is interest in it, so I’ll try to take a look at it soon and see what I can do to get it working.
February 27th, 2009 at 3:41 pm
Paul Robertson is reported to have said:
For everyone who’s asked (and I’m surprised how many have), I’ve got a beta (barely tested) version of the library with support for Flash Player-only projects (no AIR dependencies). See the full post for details.
March 19th, 2009 at 4:15 am
Mark Lynch is reported to have said:
Hi Paul,
Thanks for the great piece of code - I’ve taken your new version and used it with Anirudh’s code (with some minor modification) to make a drop in replacement for HTTPService which will handle both gzip’d and non gzip’d content.
http://www.learnosity.com/techblog/index.cfm/2009/3/19/More-of-AIR-Gzip-compression
Great work.
Thanks,
Mark
March 28th, 2009 at 3:28 pm
Joe Corner-Reeve is reported to have said:
Hello guys,
Is your compression function in actionscript 3?
Wow! I think because we need high-level compression by function like WinRar, 7z or kgb compressing functions. How do i know about currect encoder by rar, 7z or kgb compressed files?
Where do i find encodes from internet?
I have problem of adobe air while my sample file will compressing onto compressed file. But adobe air application was killed by debug while compression process lose that long time.. :(
I need processbar on panel like WinRar with process panel while compressor will to be final created compressed files?
Thank you! Ragards, Joe Corne-Reeve
March 30th, 2009 at 11:40 am
Paul Robertson is reported to have said:
@Joe:
The compression is built into AIR/Flash Player, so it runs in native code, not in ActionScript. Other compression formats such as the ones you mention would either need to be included in the player or rewritten in ActionScript.
Unfortunately, the compression and decompression run synchronously in Flash Player/AIR, so there’s no way to get progress notifications (or even run any other code) while they’re running.
April 9th, 2009 at 1:57 am
k.chandra shekar is reported to have said:
hi paul
I am trying to compress the files in flex app using flash player 10 but it is not working in fp10 give me exact solution how to compress files in flex web application development not in the air
i neede so how to do pls help me the ways
bye
June 9th, 2009 at 6:37 am
Gregor Rot is reported to have said:
For flash player 10 that supports gzip comp/decomp, the only thing that needed to be changed in the code is:
data.compress(…) -> data.inflate();
data.uncompress(…) -> data.deflate();
Gregor
July 31st, 2009 at 2:24 am
Flex to REST w/ GZip return | Flex Developer forums is reported to have said:
August 7th, 2009 at 7:25 am
Matias is reported to have said:
What about split compressed files?
ie:
encoder.compressToFile(source, destination, limitPerFile);
Can I do this?
Any idea?
August 13th, 2009 at 9:31 am
Paul Robertson is reported to have said:
Matias,
The library doesn’t support “split” compressed files. I based the library on the GZIP spec, and it doesn’t say anything about a standard way of splitting files (unless I missed it or they’ve added it in since then). If you know of a standard way of doing it, or you’ve seen another GZIP implementation that provides that support, let me know and I can try to research it and implement it. Otherwise, it doesn’t seem to make sense to implement that as a feature since other GZIP implementations wouldn’t be able to understand how to decompress the files.
January 12th, 2010 at 12:17 pm
Adobe AIR SOAP WebService Compression « Norvinet's Blog is reported to have said:
[…] http://probertson.com/projects/gzipencoder/ […]
January 14th, 2010 at 11:17 am
Ross R is reported to have said:
I am trying to implement this to compress an XML String which will be sent to JS via ExternalInterface, and then posted to a C# page.
It isn’t working at the moment, because I don’t seem to be able to get a String representation of the compressed ByteArray. For some reason, the JS fires off an error as soon as I pass the byteArray string to it “unterminated string element” or some such.
Any ideas how I can make this work for my purposes?
January 18th, 2010 at 3:03 pm
Paul Robertson is reported to have said:
Hi Ross,
You can’t directly get a string representation of a ByteArray. (Well, you can try, but chances are some of the characters will be outside the normal character range.) One common way of string-encoding binary data is to convert the ByteArray to a Base64-encoded string. You would then need to decode it to binary again on your server.
Flex SDK includes a Base64Encoder class that will do the Base64 encoding for you. You just pass the ByteArray to your Base64Encoder and then call toString() to get the Base64 string.
February 24th, 2010 at 10:01 pm
HOW TO COMPRESS FILES AT THE CLIENT END IN ADOBE AIR : 93920 is reported to have said:
[…] http://probertson.com/projects/gzipencoder/ […]
February 27th, 2010 at 12:10 pm
Carlos Bueno: A Dismal Guide to Bandwidth is reported to have said: