Reputation: 397
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.
Then I found this answer offered a tip on inspecting chrome://quota-internals/
, the page mysteriously shows the correct stat.
This chrome developer blog illustrates how accurate is the estimate, but it doesn't help much.
Upvotes: 3
Views: 633
Reputation: 4483
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.
Upvotes: 3