Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filesystem API not working in Chrome v27 & v29

I'm trying to set up a file storage for later use in Phonegap, but debugging in Chrome for now. Going the way as described on html5rocks only lets me request a quota from the user, but the callback when requesting the filesystem is not executed. See:

window.webkitStorageInfo.requestQuota(PERSISTENT, 1024*1024*1024, function(grantedBytes) {
    requestFS(grantedBytes);
}, onError);

function requestFS(grantedBytes) {
    window.webkitRequestFileSystem(window.PERSISTENT, grantedBytes, function(fs) {
        // ... does not get called ###################################
    }, onError);
}

Now Chrome warns me that webkitStorageInfo has been deprecated and there is a new standard out from today https://dvcs.w3.org/hg/quota/raw-file/tip/Overview.html. I tried using navigator.webkitPersistentStorage without success.

Is it possible the filesystem API is not working currently or has been deprecated or is possibly something wrong with my above code?

Below functions also don't do anything, no errors visible:

navigator.webkitPersistentStorage.queryUsageAndQuota(function(usage, quota) {
    console.log(arguments);

    navigator.webkitPersistentStorage.requestQuota(1024 * 1024, function(grantedQuota) {
        console.log(arguments);

        window.webkitRequestFileSystem(window.PERSISTENT, 1024 * 1024, function(fs) {
            console.log(arguments);
        });
    });
});

UPDATE:

I got Filer by Eric Bidelman working, so something in my code must be wrong, though I can't see a difference between the Filer init method and what I'm doing.

like image 206
Benjamin E. Avatar asked Jun 18 '13 08:06

Benjamin E.


1 Answers

I'm running Chorme 27 and the follwoing appears to work, showing the log message indicated

function onError () { console.log ('Error : ', arguments); }

navigator.webkitPersistentStorage.requestQuota (1024*1024*1024, function(grantedBytes) {
  console.log ('requestQuota: ', arguments);
  requestFS(grantedBytes);
}, onError);

function requestFS(grantedBytes) {
  window.webkitRequestFileSystem(window.PERSISTENT, grantedBytes, function(fs) {
    console.log ('fs: ', arguments); // I see this on Chrome 27 in Ubuntu
  }, onError);
}

Basically I changed window.webkitStorageInfo.requestQuota in your original code to navigator.webkitPersistentStorage.requestQuota and removed the PERSISTENT parameter

like image 153
HBP Avatar answered Sep 28 '22 02:09

HBP