我想获得可以在indexedDB中存储的用于存储许多大型二进制文件的上限,而 StorageManager.estimate()
报告的值比我的实际可用磁盘空间大得多。
然后我发现这个 answer 提供了检查 chrome://quota-internals/
的提示,该页面神秘地显示了正确的统计数据。
这个 chrome developer blog 说明了估算的准确性,但没有多大帮助。
最佳答案
The storage quota of a storage shelf is an implementation-defined conservative estimate of the total amount of bytes it can hold. This amount should be less than the total storage space on the device. It must not be a function of the available storage space on the device.
返回的值并非基于设备上的实际可用空间,而是小于设备总容量的量,并且基于与用户参与度相关的多个因素。其背后的原因是:
Directly or indirectly revealing available storage space can lead to fingerprinting and leaking information outside the scope of the origin involved.
This article指出 Chrome 允许源最多使用总磁盘空间的 60%,这与我在查询配额时看到的结果一致。无法获得实际的可用空间。目前,Chrome 将始终将配额报告为总磁盘空间的 %60,除非在某些情况下(例如在隐身模式下浏览时)。其他浏览器的行为可能有所不同,因为具体如何实现此功能由浏览器供应商决定。
关于google-chrome - Chrome StorageManager API 报告配额远大于预期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72405318/