获取blob名称列表时出现"填充不正确"错误
- azure-storage-blob:
- 版本 12.19.1:
- 操作系统 Windows 10:
- Python 版本 3.10.6:
- 文件数量超过 10,000 个:
问题描述
在尝试从 Azure Blob 存储容器中获取 blob 名称列表时,遇到了一个“错误的填充”错误。这意味着在获取 blob 名称时遇到了问题,虽然上传和下载 blob 的操作都成功了。
代码片段:
try:
# Get the list of blobs in the container
blob_list = self.container_client.list_blobs()
print("List of blobs:")
for blob in blob_list:
print(blob.name)
except Exception as e:
print(f"An error occurred while retrieving the list of blobs: {str(e)}")
错误信息:
错误的填充
其他成功的操作:
- 上传 Blob
def upload(self, blob_data, blob_name):
try:
# Upload a blob to the container
self.container_client.upload_blob(name=blob_name, data=blob_data)
print(f"Blob '{blob_name}' uploaded successfully.")
except Exception as e:
print(f"An error occurred while uploading blob '{blob_name}': {str(e)}")
- 下载 Blob
def download(self, blob_name):
try:
# Get the BlobClient for the blob
blob_client = self.container_client.get_blob_client(blob_name)
# Download the blob to a local file
with open(blob_name, "wb") as blob:
download_stream = blob_client.download_blob()
blob.write(download_stream.readall())
print(f"Blob '{blob_name}' downloaded successfully.")
except Exception as e:
print(f"An error occurred while downloading blob '{blob_name}': {str(e)}")