Filesystem API not working in Chrome v27 & v29
Asked Answered
B

1

6

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.

Behlau answered 18/6, 2013 at 8:59 Comment(0)
I
8

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

Internationalist answered 21/6, 2013 at 4:13 Comment(2)
But that's exactly what I did, isn't it? I guess the failure was more complex, since I plugged it into an existing extensive application. Anyway, thanks for trying it out and Filer.js got me on the right track.Behlau
I'm running on chrome 27.0.1453.116 and this code is not working .. :\ I'm getting an FileError.INVALID_MODIFICATION_ERRBaggywrinkle

© 2022 - 2024 — McMap. All rights reserved.