Reputation: 158
I used the google drive API to find out how much space I have left on my drive.
result = GoogleDrive.service.about().get(fields = "quotaBytesTotal, quotaBytesUsed").execute()
And it return me : {"quotaBytesTotal": "16106127360", "quotaBytesUsed": "687529945"}
16106127360 Bytes = 16.10612736 Go
687529945 Bytes = 0.687529945 Go
But, If I verify on my drive :
Why 16.1 =! 15
and 687 != 848
Why I haven't the same result from using API and from drive UI
Upvotes: 0
Views: 66
Reputation: 15377
For each new prefix for bytes
, you must multiply by 1024 instead of 1000:
1 kB = 1024 Bytes
1 MB = 1024 kB = 1,048,576 Bytes
1 GB = 1024 MB = 1,048,576 kB = 1,073,741,824 Bytes
15 Gigabytes = (15 * 1,073,741,824 Bytes) = 16,106,127,360 Bytes
Which is your total Bytes Quota.
As for quotaBytesUsed
- this accounts for files stored in Drive only, whereas the quota viewable in the UI includes files that are stored in other services that also use the same storage. As per the documentation on the About resource:
Property Name Value Description Notes quotaBytesUsed
long
The number of quota bytes used by Google Drive.
To get the value reflected in the Drive UI, instead, use the field value quotaBytesUsedAggregate
:
Property Name Value Description Notes quotaBytesUsedAggregate
long
The number of quota bytes used by all Google apps (Drive, Picasa, etc.).
result = GoogleDrive.service.about().get(fields = "quotaBytesTotal, quotaBytesUsedAggregate").execute()
This should return the accurate value.
Upvotes: 1