2015-04-02 85 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