Google chrome 文件系统赢得';我不能给我的Chrome扩展空间
我正在开发一个chrome扩展,并将其作为一个未打包的扩展进行测试 我设法达到了可以请求配额和文件系统的程度,但它不会授予任何空间 从background.js:Google chrome 文件系统赢得';我不能给我的Chrome扩展空间,google-chrome,google-chrome-extension,persistent-storage,html5-filesystem,Google Chrome,Google Chrome Extension,Persistent Storage,Html5 Filesystem,我正在开发一个chrome扩展,并将其作为一个未打包的扩展进行测试 我设法达到了可以请求配额和文件系统的程度,但它不会授予任何空间 从background.js: chrome.runtime.onMessage.addListener( function() { navigator.webkitPersistentStorage.queryUsageAndQuota( function(usedQuota, grantedQuota)
chrome.runtime.onMessage.addListener(
function()
{
navigator.webkitPersistentStorage.queryUsageAndQuota(
function(usedQuota, grantedQuota)
{
console.log(usedQuota + " of " + grantedQuota);
}
);
let requestedBytes = 1024 * 1024 * 10; //10mb
navigator.webkitPersistentStorage.requestQuota(
requestedBytes,
function(grantedBytes)
{
window.webkitRequestFileSystem(
PERSISTENT,
grantedBytes,
function (filesystem)
{
console.log("Name: " + filesystem.name);
console.log("Requested Size " + (requestedBytes / 1024 / 1024))
console.log("Granted Size: " + (grantedBytes / 1024 / 1024));
},
function (fileerror) {console.log("Error: " + fileerror);}
)
}
);
}
);
我有一个index.html,它发送一条消息,激活上面的代码
但我只能将其输出到以下内容:
0 of 0
background.js:29 Name: chrome-extension_dpgmepaclcikglfooaopnbockbeenlbd_0:Persistent
background.js:30 Requested Size 10
background.js:31 Granted Size: 0
manifest.json:
{
"manifest_version": 2,
"name": "SomeRandomName",
"version": "0.1",
"browser_action":
{
},
"permissions":
[
],
"background":
{
"scripts": ["background.js"],
"persistent": false
},
"content_security_policy": "script-src 'self' 'sha256-d8KCEnecXtiRMS4Kj2vm8/UElPKEk5YsgZWRWitb0O8='; object-src 'self'" //debug
}
这是怎么回事?显然,在权限中添加“未受限制的存储”可以修复它。但我认为有一种方法可以做到这一点,而不需要无限的存储空间。尝试在
权限中添加“unlimitedStorage”
。也有可能是Chrome中有一个bug……它起作用了。我想如果你不超过一定的量,你就不应该需要它。