【发布时间】:2017-12-18 13:29:41
【问题描述】:
我正在尝试构建一个只需要在 Chrome 浏览器中运行的应用程序。 部分原因是可以使用拖放功能上传文件夹。
我现在面临的问题是我什至无法创建一个临时文件夹来复制拖放的文件/文件夹。
下面是代码
navigator.webkitPersistentStorage.requestQuota(1024 * 1024 * 500, function (bytes) {
console.log('Allocated ' + bytes + ' bytes.');
// request file system
window.webkitRequestFileSystem(PERSISTENT, bytes, function(fileSystem) {
fs = fileSystem;
cwd = fs.root;
//log query usage and quota
navigator.webkitPersistentStorage.queryUsageAndQuota(
(used, total) => console.log(
`using ${used} out of ${total}, or ${used/total*100}%`)
);
//create temp folder
cwd.getDirectory('/temp', {create: true, exclusive: true}, function(directory){
multiplefilesDirectory = directory;
console.log('directory',directory,multiplefilesDirectory);
}, onError);
});
}, function (e) {
console.log('Failed to allocate persistant storage!');
});
requestQuota 没有错误。它记录Allocated 524288000 bytes.
queryUsageAndQuota 记录了using 0 out of 0, or NaN%,看起来存储大小没有改变。
临时文件夹的创建记录错误Error: The operation failed because it would cause the application to exceed its storage quota.。可能是因为存储大小不变。
是我犯了错误还是有其他方法可以做到这一点?
【问题讨论】:
-
我认为 chrome 的存储空间没有足够的空间存放这些东西
标签: javascript google-chrome html5-filesystem