【发布时间】:2019-06-25 05:10:05
【问题描述】:
我可以从gsutil 获得尺寸。
✗ gsutil du gs://<bucket>/test/1561402306
100 gs://<bucket>/test/1561402306
我可以通过download_as_string 确认长度和内容。但是,size 属性始终从 SDK/API 返回 None。
如何在不下载的情况下获取 Cloud Storage 对象的大小?
from google.cloud import storage
client = storage.Client()
bucket = client.get_bucket(bucket_name)
blob = bucket.blob(blob_name)
print(len(blob.download_as_string().decode()))
print(blob.size)
输出:
100
None
【问题讨论】:
标签: python google-cloud-platform google-cloud-storage google-cloud-python