2

I want to get the upper limit I can store in indexedDB for storing many large binary files, while StorageManager.estimate() reports much bigger than my real free disk space.

enter image description here

enter image description here

Then I found this answer offered a tip on inspecting chrome://quota-internals/, the page mysteriously shows the correct stat. enter image description here

This chrome developer blog illustrates how accurate is the estimate, but it doesn't help much.

crazyones110
  • 296
  • 3
  • 18

1 Answers1

2

The Storage API spec says :

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.

The value returned is not based on the actual free space available on the device but rather an amount less than the total capacity of the device and based on several factors related to user engagement. The reasoning behind this is :

Directly or indirectly revealing available storage space can lead to fingerprinting and leaking information outside the scope of the origin involved.

This article states that Chrome allows an origin to use up to a maximum of 60% of the total disk space which is consistent with the results I see when querying the quota. There is no way to get the actual free space available. At this time, Chrome will always report the quota as %60 of the total disk space except in certain situations like when browsing in Incognito Mode. Other browsers may behave differently as it is up to the browser vendors to decide exactly how this feature is implemented.

Besworks
  • 4,123
  • 1
  • 18
  • 34
  • 1
    So `chrome://quota-internals/` is actually a backdoor to expose the actual available space while `Storage` API is designed to estimate the quota based on the total disk space? There is no workaround about this, I should carefully capture `QuotaExceededError` and prompt to users if I want to store large binary files. – crazyones110 May 30 '22 at 02:15