如何从 Azure 中的 ResourceProperties 对象检查状态

How to check status from ResourceProperties object in Azure

我是 Azure 的新手。我正在使用 Blobstorage 像这样在 python 中存储我的项目文件。

response=block_blob_service.create_blob_from_stream(settings.CONTAINER_NAME+"/"+"headers",s3_key,file_upload)

如果我打印响应,我会得到以下对象。

   <azure.storage.blob.models.ResourceProperties object at 0x7fbbd05dbb70>

如何检查响应对象的状态。

您可以在此处查看 azure.storage.blob.models.ResourceProperties 的定义:https://github.com/Azure/azure-storage-python/blob/master/azure-storage-blob/azure/storage/blob/models.py#L366

您可以使用

获取它
blob = blob_svc.get_blob_properties(
        container_name=AZURE_CONTAINER,
        blob_name=AZURE_BLOB_NAME)

total_bytes = blob.properties.content_length
print('--> Sent', total_bytes, 'bytes')

How can i check the status from the response object.

来自 response=block_blob_service.create_blob_from_streamresponse 对象只有 returns 2 个属性:etaglast_modified。如果要使用这 2 个属性,可以轻松使用 response.etagresponse.last_modified

我在visual studio代码中调试,截图如下:

我想你想检查状态以查看 blob 是否已完整上传。如果是这样,你应该知道方法create_blob_from_stream同步方法。在完成上传之前,它会 returns 响应。

我正在使用 python 3.7 和 azure-storage-blob==1.5.0。