gpt4 book ai didi

javascript - Html 5 文件系统 API,我收到 DOMError "NotSupporteError"

转载 作者:搜寻专家 更新时间:2023-10-31 22:45:30 25 4
gpt4 key购买 nike

我正在尝试在 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,但我得到了完全相同的错误。

最佳答案

我想你的问题可能出在这里:

The application has been only tested locally (i.e. just open the html file with Chrome).

当您在 file:///协议(protocol)上运行时,您不会获得与 http/s:///相同的特权

如果我是你,我会尝试通过网络服务器运行它。

关于javascript - Html 5 文件系统 API,我收到 DOMError "NotSupporteError",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20594804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com