gpt4 book ai didi

python - Azure 服务器无法对请求进行身份验证

转载 作者:行者123 更新时间:2023-12-03 04:49:32 25 4
gpt4 key购买 nike

我正在尝试使用 Jupyter Notebook 将 blob 上传到 Azure 存储。我有一个示例代码如下:

from azure.storage.blob import BlockBlobService

accountName = "< account name>"
ContainerSAS = "<SAS key>"
containerName = "< container name>"

try:
sas_service = BlockBlobService(account_name=accountName, sas_token=ContainerSAS)
except Exception as e:
print("There was an error during SAS service creation. Details: {0}".format(e))

from azure.storage.blob import ContentSettings

blobName = "< blob name >"
try:
sas_service.create_blob_from_path(
'accountName',
'blobName',
'Chicago_Crime_Data-v2.csv',
content_settings=ContentSettings(content_type='Chicago_Crime_Data-v2/csv')
)
except Exception as e:
print("There was an error during blob uploading. Details: {0}".format(e))

但我收到一条错误消息:详细信息:服务器无法验证请求。确保授权 header 的值格式正确,包括签名。

我无法理解这里出了什么问题。我是新手。任何帮助将非常感激。谢谢。

编辑:我应该提供帐户名称、容器名称和 key 吗?

最佳答案

我的本​​地文件路径是“./rootfolder”,然后当它找到要上传的文件时,它会像 file="./rootfolder/folder/file.dcm"

然后我尝试批量上传该文件:

blob_client = blob_service_client.get_blob_client(container=container_name, blob=file)

然后我收到以下错误:

Azure Server failed to authenticate the request

AuthenticationErrorDetail:The MAC signature found in the HTTP request '' is not the same as any computed signature. Server used following string to sign: 'PUT...

我发现您必须执行类似的操作,从文件路径中删除 ./

file_path_on_azure = file_name.replace("./", "")

blob_client = blob_service_client.get_blob_client(container=container_name, blob=file_path_on_azure)

关于python - Azure 服务器无法对请求进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58164698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com