我们有一个用于云中大量数据的“Azure Blob 存储”。我们有包含多个目录的 blob 容器,在每个目录中,我们有几个类型为“Block Blob”的 blob 文件,它们是“.orc”文件。我们需要使用 blob 的路径列出此类目录的内容,然后获取特定的 blob 信息,最重要的是每个 blob 的文件大小。目前,我们正计划为其使用“azure-storage-python”,但目前在其文档中丢失,并且对如何实现我们的目标感到困惑。 任何帮助将不胜感激!急切等待回应!
1 回答
繁华开满天机
TA贡献1816条经验 获得超4个赞
如果要列出每个 blob 的文件大小。有一个很直接的方法:
# Create the BlobServiceClient that is used to call the Blob service for the storage account
conn_str = ' '
blob_service_client = BlobServiceClient.from_connection_string(conn_str=conn_str)
container_name = ' '
# List the blobs's information in the container
print("\nList blobs in the container")
container = blob_service_client.get_container_client(container=container_name)
generator = container.list_blobs()
for blob in generator:
print("\t Blob name: " + blob.name)
print("\t Blob size: "+ str(blob.size))
它以我的方式工作。
如果要列出 blob 的所有信息,只需执行print(blob)
.
添加回答
举报
0/150
提交
取消