views:

25

answers:

1

I need to be able to take a javascript string, compress it using any fast and available means and get back a binary string/blob.

Background:

The extension I'm developing needs to send various large content to my server. It does this conveniently by dynamically creating a form, adding fields to the form and posting it. Some of these fields are just too big bandwidth wise for multiple use. I'd like to be able to compress them before adding them and then maybe base64'ing them if the characters cause a problem in the message. Any ideas?

I could use nsiZipWriter with temporary files on disk but that is quite ugly and probably sluggish.

A: 

I decided to use LiveConnect to connect to a java class that I wrote to deflate/inflate the data. This seems to be the most elegant way of adding functionality to javascript that isn't there without compiling C++ XPCOM for each platform, and the potential of reusing it in other browsers. Slight performance penalty the first time the JVM loads.

http://stanislavvitvitskiy.blogspot.com/2009/04/calling-java-from-xul-applications.html

Daniel