在Firefox中读取和写入大量数据到用户的本地存储 [英] Reading and writing large amounts of data to a user's local storage in Firefox

查看:206
本文介绍了在Firefox中读取和写入大量数据到用户的本地存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我们有一个复杂的HTML5离线应用程序,其中包含大量的数据(我们说的是数十兆字节),我们想要读取并写入用户磁盘的副本。



我们已经开始使用HTML5 IndexedDB了,但Chrome的数据量很大(加载时间约为10分钟),而且当前版本的Firefox有愚蠢的速度被认为这是唯一的方法,因为Gecko严格隔离特权页面(如我们的扩展名)和非特权页面(如我们的网站)。还有其他解决方案吗?

解决方案

您的扩展程序代码可以从网页读取任意数据。它只需要通过获取它正在处理的任何对象的 .wrappedJSObject 属性来选择它,以获得它的网页视图。


So we've got a complex HTML5 offline app that contains a big old wodge of data (we're talking tens of megabytes), and we'd like to read and write copies of it to the user's disk.

We've already got this kinda-sorta working with HTML5 IndexedDB, but Chrome is stupidly slow with large amounts of data (~10 min to load) and current versions of Firefox have a lovely bug that randomly and irretrievably trashes the entire DB, so this is plan B -- plus we'd really like to have a user-specifiable file that they can then backup, mail around, etc.

Obviously we can't do this with normal browser privileges, but Firefox extensions outside the sandbox can access the file system, and we've gotten the basic concept working with this extension. Only problem is, the extension passes data around by reading and writing DOM attributes, which seems less than ideal for the volume of data we're talking about:

However, if this is to be believed this is really is the only way to do it, since Gecko strictly segregates privileged pages (like our extension) and non-privileged pages (like our website). Is there another solution?

解决方案

Your extension code can read arbitrary data from the web-page. It just has to opt in to that by getting the .wrappedJSObject property of whatever object it's working on, to get the "web page" view of it.

这篇关于在Firefox中读取和写入大量数据到用户的本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆