2015-04-02 91 views
1

我正在开发可用作备忘录的Chrome扩展。Chrome扩展请求本地存储配额超时错误

我搜索了互联网,发现chrome.storage API可能对我有用。

但是,我总是在本地请求存储时遇到“QuotaExceededError”。

这里是我的javascript代码:

window.onload = function() { 
    openLocalFileSystem(true); 
} 
function openLocalFileSystem(isReadMode) { 
    navigator.webkitPersistentStorage.requestQuota(1024 * 1024 * 10, function(grantBytes) { 
     window.webkitRequestFileSystem(window.PERSISTENT, grantBytes, 
     function(fs) { 
      console.log(grantBytes); // ALWAYS 0! WHY??? 
      onFileSystemOpened(fs, isReadMode); 
     }, 
     function(e) { 
      console.log("Couldn't request file system!"); 
     }); 
    }); 
} 

有人可以帮助我在这里?非常感谢!!!

回答

1

chrome.storage API特定于Chrome应用并与LocalFileSystem Storage分开。

要从Chrome应用程序使用requestQuota,您应该在manifest.json文件中添加unlimitedStorage权限。

+0

我在我的json文件中请求了权限:“permissions”:[“syncFileSystem”,“unlimitedStorage”]。但仍然不起作用 – Mapleman 2015-04-02 18:17:48

+0

我用存储/ localStorage的unlimitedStorage很好,但它可能不适用于文件系统存储? – 2015-04-04 16:22:22