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);
});
});
});
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With