【发布时间】:2013-12-15 21:02:49
【问题描述】:
我正在尝试在 chrome 31 中使用 HTML5 文件系统 API。不幸的是,在用户授予对文件系统配额的访问权限后,我收到错误消息。
这是错误:
Error DOMError {message: "The implementation did not support the requested type of object or operation.", name: "NotSupportedError"}
我正在使用的代码:
<!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>
该应用程序仅在本地进行了测试(即仅使用 Chrome 打开 html 文件)。
我也尝试了 filer.js,但我得到了完全相同的错误。
【问题讨论】:
标签: javascript html google-chrome html5-filesystem