Google 开车 15 GO 但 API return 我 16.1 GO
Google Drive 15 GO but API return me 16.1 GO
我使用 google 驱动器 API 来查看我的驱动器上还剩多少 space。
result = GoogleDrive.service.about().get(fields = "quotaBytesTotal, quotaBytesUsed").execute()
它 return 我 : {"quotaBytesTotal": "16106127360", "quotaBytesUsed": "687529945"}
16106127360 字节 = 16.10612736 去
687529945 字节 = 0.687529945 去
但是,如果我在我的驱动器上验证:
为什么 16.1 =! 15
和 687 != 848
为什么我使用 API 和驱动器 UI
的结果不同
对于 bytes
的每个新前缀,您必须乘以 1024 而不是 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
您的总字节配额是多少。
至于 quotaBytesUsed
- 这只考虑了存储在云端硬盘 中的文件 ,而 UI 中可见的配额包括存储在其他文件中的文件也使用相同存储的服务。根据 About resource 上的文档:
Property Name
Value
Description
Notes
quotaBytesUsed
long
The number of quota bytes used by Google Drive.
要获取反映在驱动器 UI 中的值,请改为使用字段值 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()
这应该是 return 准确的值。
我使用 google 驱动器 API 来查看我的驱动器上还剩多少 space。
result = GoogleDrive.service.about().get(fields = "quotaBytesTotal, quotaBytesUsed").execute()
它 return 我 : {"quotaBytesTotal": "16106127360", "quotaBytesUsed": "687529945"}
16106127360 字节 = 16.10612736 去
687529945 字节 = 0.687529945 去
但是,如果我在我的驱动器上验证:
为什么 16.1 =! 15
和 687 != 848
为什么我使用 API 和驱动器 UI
对于 bytes
的每个新前缀,您必须乘以 1024 而不是 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
您的总字节配额是多少。
至于 quotaBytesUsed
- 这只考虑了存储在云端硬盘 中的文件 ,而 UI 中可见的配额包括存储在其他文件中的文件也使用相同存储的服务。根据 About resource 上的文档:
Property Name Value Description Notes quotaBytesUsed
long
The number of quota bytes used by Google Drive.
要获取反映在驱动器 UI 中的值,请改为使用字段值 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()
这应该是 return 准确的值。