【问题标题】:Couldn't create folder in storage Chrome无法在存储 Chrome 中创建文件夹
【发布时间】: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


【解决方案1】:

检查文件系统上的可用空间。

就我而言,可用磁盘空间存在问题。我要求 1*1024*1024 并且从 1TB 磁盘中有 7 GB 可用空间,使用 df -h 时已 100% 满。 删除 28GB 以达到 97% 的容量并开始工作。

【讨论】:

    猜你喜欢
    • 2020-11-17
    • 1970-01-01
    • 2016-07-21
    • 2021-12-14
    • 1970-01-01
    • 2014-04-17
    • 1970-01-01
    • 1970-01-01
    • 2020-05-09
    相关资源
    最近更新 更多