使用 nsIZipWriter 或其他将字符串压缩为字符串?
我需要能够获取 JavaScript 字符串,使用任何快速且可用的方法对其进行压缩,然后返回二进制字符串/blob。
背景:
我正在开发的扩展需要将各种大内容发送到我的服务器。 它通过动态创建表单、向表单添加字段并发布它来方便地完成此操作。其中一些字段的带宽太大,无法多次使用。我希望能够在添加它们之前对其进行压缩,然后如果字符在消息中引起问题,则可以对它们进行 base64 处理。有什么想法吗?
我可以将 nsiZipWriter 与磁盘上的临时文件一起使用,但这非常难看,而且可能很慢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我决定使用 LiveConnect 连接到我编写的用于压缩/膨胀数据的 java 类。这似乎是向 javascript 添加功能的最优雅的方式,而无需为每个平台编译 C++ XPCOM,并且具有在其他浏览器中重用它的潜力。第一次加载 JVM 时性能会受到轻微影响。
http://stanislavvitvitskiy.blogspot.com/2009/ 04/从-xul-applications.html调用java-from-xul-applications.html
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