【问题标题】:Set quota for HTML5 File API in NW.js application在 NW.js 应用程序中为 HTML5 文件 API 设置配额
【发布时间】:2015-03-13 11:06:00
【问题描述】:

如何在 NW.js 应用程序中设置 HTML5 文件 API 的配额?

这是我的 package.json

{
  "name": "test",
  "main": "index.html",
  "dom_storage_quota": 1024,
  "window": {
    "width": 1024,
    "height": 600
  }
}

当我尝试使用 HTML5 文件 API 保存文件时,我收到 QuotaExceededError 错误。

webkitStorageInfo表示即使设置"dom_storage_quota": 1024后我的配额也是0

window.webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.PERSISTENT, function(used, remaining) {
  console.log("Used quota: " + used + ", remaining quota: " + remaining);
}, function(e) {
  console.log('Error', e);
});

已用配额:0,剩余配额:0

【问题讨论】:

    标签: javascript html node-webkit nw.js


    【解决方案1】:

    PERSISTENT 存储的默认配额为 0。您需要使用配额管理 API 中的 requestQuota() 方法

    webkitStorageInfo.requestQuota(
      webkitStorageInfo.PERSISTENT
      newQuotaInBytes,
      quotaCallback,
      errorCallback);
    

    【讨论】:

      猜你喜欢
      • 2023-04-11
      • 2021-05-02
      • 2021-02-05
      • 1970-01-01
      • 2016-07-14
      • 1970-01-01
      • 2020-12-07
      • 2013-04-06
      • 2010-09-15
      相关资源
      最近更新 更多