Mapleman
Mapleman

Reputation: 45

Chrome Extension Request Local Storage QuotaExceededError

I'm developing a chrome extension that can be used as a memo.

I searched the Internet and found chrome.storage APIs might be useful in my case.

However, I always encountered a "QuotaExceededError" when I request storage locally.

Here is my javascript code:

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!");
        });
    });
}

Can someone help me out here? Thanks a lot!!!

Upvotes: 1

Views: 972

Answers (1)

lostsource
lostsource

Reputation: 21850

The chrome.storage API is specific to Chrome Apps and separate from LocalFileSystem Storage.

In order to use requestQuota from a Chrome App you should add the unlimitedStorage permission in your manifest.json file.

Upvotes: 1

Related Questions