最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Filesystem API not working in Chrome v27 & v29 - Stack Overflow

programmeradmin2浏览0评论

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 .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.

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/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.

Share Improve this question edited Jun 21, 2013 at 3:29 Benjamin E. asked Jun 18, 2013 at 8:59 Benjamin E.Benjamin E. 5,1725 gold badges40 silver badges67 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 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

发布评论

评论列表(0)

  1. 暂无评论