文件系统API在Chrome v27& v29 [英] Filesystem API not working in Chrome v27 & v29

查看:394
本文介绍了文件系统API在Chrome v27& v29的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置一个文件存储,供以后在Phonegap中使用,但现在在Chrome中调试。按照 html5rocks 中所述的方式,只允许我请求用户,但是不会执行请求文件系统时的回调。请参阅:

  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 #### ############################### b $ b},onError);
}

现在Chrome警告我webkitStorageInfo已被弃用,从今天开始 https://dvcs.w3.org/hg/quota/raw-file/ tip / Overview.html 。我尝试使用navigator.webkitPersistentStorage没有成功。



文件系统API可能目前不工作,或已被弃用或可能是我的上述代码有问题吗? p>

下面的函数也不做任何事情,没有可见的错误:

  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:



href =https://github.com/ebidel/filer.js> Filer 由Eric Bidelman工作,所以我的代码中的东西一定是错误的,虽然我看不到Filer init方法之间的区别

解决方案

我正在运行Chorme 27并且其后果似乎工作,显示日志消息指示

  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) /我看到这个在Chrome 27在Ubuntu
},onError);
}

基本上我改变了 window.webkitStorageInfo.requestQuota ,并将 PERSISTENT 参数

移除,并将原始程式码中的code>移至 navigator.webkitPersistentStorage.requestQuota

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.

解决方案

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

这篇关于文件系统API在Chrome v27& v29的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆