I want to develop an addon with the addon builder. I read that with simple storage one can have about 5 megabytes for his addon, but 5 mgb won't do it for my app. I need more. What could I do?
我想用插件构建器开发一个插件。我看到,通过简单的存储,他的插件可以有大约5兆字节,但5毫克不会为我的应用程序做到这一点。我需要更多。我能做什么?
1 个解决方案
#1
3
You cannot do much given the Add-on SDK API. Instead you could break out of the sandbox and create a file in user's profile directory (see File I/O code snippets). E.g. something along these lines to read the file myData.txt
from user's profile:
鉴于Add-on SDK API,您无法做很多事情。相反,您可以打破沙箱并在用户的配置文件目录中创建文件(请参阅文件I / O代码片段)。例如。沿着这些行读取用户配置文件中的文件myData.txt:
var {Cu, components} = require("chrome");
var {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm");
var {NetUtils} = Cu.import("resource://gre/modules/NetUtil.jsm");
var file = FileUtils.getFile("ProfD", ["myData.txt"]);
NetUtil.asyncFetch(file, function(inputStream, status) {
if (!components.isSuccessCode(status)) {
// Handle error!
return;
}
// The file data is contained within inputStream.
// You can read it into a string with
var data = NetUtil.readInputStreamToString(inputStream, inputStream.available());
console.log(data);
});
Note that the unusual syntax to import modules is due to bug 683217.
请注意,导入模块的异常语法是由于错误683217。
#1
3
You cannot do much given the Add-on SDK API. Instead you could break out of the sandbox and create a file in user's profile directory (see File I/O code snippets). E.g. something along these lines to read the file myData.txt
from user's profile:
鉴于Add-on SDK API,您无法做很多事情。相反,您可以打破沙箱并在用户的配置文件目录中创建文件(请参阅文件I / O代码片段)。例如。沿着这些行读取用户配置文件中的文件myData.txt:
var {Cu, components} = require("chrome");
var {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm");
var {NetUtils} = Cu.import("resource://gre/modules/NetUtil.jsm");
var file = FileUtils.getFile("ProfD", ["myData.txt"]);
NetUtil.asyncFetch(file, function(inputStream, status) {
if (!components.isSuccessCode(status)) {
// Handle error!
return;
}
// The file data is contained within inputStream.
// You can read it into a string with
var data = NetUtil.readInputStreamToString(inputStream, inputStream.available());
console.log(data);
});
Note that the unusual syntax to import modules is due to bug 683217.
请注意,导入模块的异常语法是由于错误683217。