开发者

Using nsIZipWriter or other to compress a string as a string?

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开发者_JS百科 the message. Any ideas?

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜