I am trying to use the HTML5 File System API in chrome 31. Unfortunatelly, I am getting an error after a user grants access to the file system quota.
This is the error :
Error DOMError {message: "The implementation did not support the requested type of object or operation.", name: "NotSupportedError"}
Code I am using :
<!DOCTYPE html>
<html>
<head>
<title> JavaScript File System </title>
<script>
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
navigator.webkitPersistentStorage.requestQuota(1024*1024, function(grantedBytes) {
window.requestFileSystem(PERSISTENT, grantedBytes, onInitFs, errorHandler);
}, function(e) {
console.log('Error', e);
});
function onInitFS(fs){
alert("Welcome to Filesystem! It's showtime :)"); // Just to check if everything is OK :)
// place the functions you will learn bellow here
}
function errorHandler(e) {
var msg = '';
switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
break;
case FileError.INVALID_MODIFICATION_ERR:
msg = 'INVALID_MODIFICATION_ERR';
break;
case FileError.INVALID_STATE_ERR:
msg = 'INVALID_STATE_ERR';
break;
default:
msg = 'Unknown Error';
break;
};
console.log('Error: ' + msg);
}
</script>
</head>
<body>
</body>
</html>
The application has been only tested locally (i.e. just open the html file with Chrome).
I tried also filer.js, but I got the same exactly error.
I think your problem might be here:
The application has been only tested locally (i.e. just open the html file with Chrome).
When you're running on the file:/// protocol you don't get the same privileges as with http/s:///
I would try running it through a web server if I were you.