我正在尝试设置文件存储以供稍后在 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 ###################################
}, onError);
}
现在 Chrome 警告我 webkitStorageInfo 已被弃用,并且从今天起有一个新标准https://dvcs.w3.org/hg/quota/raw-file/tip/Overview.html。我尝试使用 navigator.webkitPersistentStorage 但没有成功。
文件系统 API 当前是否无法工作或已被弃用,或者我的上述代码可能有问题?
以下函数也不执行任何操作,没有可见错误:
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作者:Eric Bidelman 正在工作,所以我的代码中一定有问题,尽管我看不出 Filer init 方法和我正在做的事情之间有什么区别。