Archive solutions in Flex/Air environment – FlashArchiver (FAR) and WINE

Posted on September 4, 2009


Using zips in a combined Flex/Air environment isn’t that trivial.
When running through FlashPlayer in browser, a compressed zip needs a Adler32 checksum to be valid. This isn’t a standard feature in any of the php zip libraries that I’ve seen.

Edwin van Rijkom’s FAR archive ( is a very slick solution to get around this. It uses a custom file format based on zip compression. In the server end, it’s command line archiving tools (win, osx and “linux”, read on…) does a neat job in compressing, and in the Flex/Air client delivers the decompressed files continously while streaming the archive – quickly enough to handle large files. The native not-quite-zip format might also initially confuse a nosy mind…

One major problem: The linux version doesn’t work well in apache-php-server environment because of dependencies of X server, wich causes “Gtk-WARNING : cannot open display” error. It might be possible to solve by creating an environment where X server is running, but that seems very unnessecary and odd for a command line tool. At least to me – wich basicaly means that it’s beyond my limited linux knowledge… πŸ™‚

One working solution: Running the windows version of the far compressing tool through Wine. Not that elegant, maybe, and maybe not that secure either, but at least it works! This is how I’ve managed to get it to work:

  1. Installing Wine on my Debian server
  2. Putting the windows archiver tool far.exe in an application directory, /var/tools/far/bin/far.exe
  3. Creating an output directory for the resulting archive files, /var/tools/far/output/, also setting it’s chown to www-data to be able to be reached by Apache.
  4. Creating a /var/www/.wine/ directory, setting its chown to www-data – also to be able to be reached by Apache2. (Maybe there’s another solution that putting it in /var/www/ – haven’t figured out yet.)
  5. Calling it from my php script like this, creating a new far archive (newarchive.far) from the files in the directory filesdirectory/:
$command = 'wine /var/tools/far/bin/far.exe /var/tools/far/output/newarchive.far filesdirectory/';
$return = exec($command, $output, $result);

Thanks Lasse for help regarding the Gtk problems, and MathieuK and Mike on StackOverflow for sorting out the Wine stuff! And Edwin of course! πŸ™‚


Tagged: , , ,
Posted in: Flex, PHP