我正在尝试使用 Python SDK 将一些更大的 blob (>50MB) 上传到我的 Azure 存储容器:
connect_str = os.environ['AZURE_STORAGE_CONNECTION_STRING']
blob_service_client = BlobServiceClient.from_connection_string(connect_str)
def upload_blob(file_path):
if os.path.exists(file_path):
with open(file_path, 'rb') as data:
blob_client = blob_service_client.get_blob_client(container='foo', blob=file_path)
print(f"Uploading file {file_path} to blob storage...")
print(os.path.getsize(file_path))
return blob_client.upload_blob(data, length=os.path.getsize(file_path))
else:
print(f"File {file_path} not found. Please store the file first before uploading")
return False
Run Code Online (Sandbox Code Playgroud)
但是,当我运行它时,我得到一个azure.core.exceptions.ServiceRequestError:
Traceback (most recent call last):
File "C:/Users/.../storage_controller.py", line 96, in <module>
upload_blob(config.VECTORIZER_PATH)
File "C:/Users/.../storage_controller.py", line 34, in upload_blob
return blob_client.upload_blob(data, length=os.path.getsize(file_path))
File "C:\Users\...\venv\lib\site-packages\azure\core\tracing\decorator.py", line 83, …Run Code Online (Sandbox Code Playgroud)