gpt4 book ai didi

azure - 如何使用 Postman 将文件上传到 Azure Blob 存储?

转载 作者:行者123 更新时间:2023-12-03 00:57:54 24 4
gpt4 key购买 nike

我正在尝试将 base64 字符串作为图像文件上传到 Azure Blob 存储。使用https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob文档尝试创建 blob。

Request Syntax:  
PUT https://myaccount.blob.core.windows.net/mycontainer/myblockblob HTTP/1.1

Request Headers:
x-ms-version: 2015-02-21
x-ms-date: <date>
Content-Type: text/plain; charset=UTF-8
x-ms-blob-content-disposition: attachment; filename="fname.ext"
x-ms-blob-type: BlockBlob
x-ms-meta-m1: v1
x-ms-meta-m2: v2
Authorization: SharedKey myaccount:YhuFJjN4fAR8/AmBrqBz7MG2uFinQ4rkh4dscbj598g=
Content-Length: 11

Request Body:
hello world

我收到如下回复,

<?xml 
version="1.0" encoding="utf-8"?>
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:a5d32623-f01e-0040-4275-c1880d000000
Time:2020-11-23T08:45:49.6994297Z</Message>
<AuthenticationErrorDetail>The MAC signature found in the HTTP request 'YhuFJjN4fAR8/AmBrqBz7MG2uFinQ4rkh4dscbj598g=' is not the same as any computed signature. Server used following string to sign: 'PUT


11

text/plain; charset=UTF-8

x-ms-blob-content-disposition:attachment; filename="demo.txt"
x-ms-blob-type:BlockBlob
x-ms-date:Mon, 23 Nov 2020 13:08:11 GMT
x-ms-encryption-key:YhuFJjN4fAR8/AmBrqBz7MG2uFinQ4rkh4dscbj598g=
x-ms-meta-m1:v1
x-ms-meta-m2:v2
x-ms-version:2015-02-21
/<myaccount>/<mycontainer>/<myblob>'.</AuthenticationErrorDetail>
</Error>

如何解决这个问题?

最佳答案

上传 blob 的一种简单方法是使用 sas token

导航到 Azure 门户 -> 您的存储帐户 -> 共享访问签名,然后选择屏幕截图中的以下选项 -> 然后单击生成 SAS 和连接字符串 按钮。截图如下:

enter image description here

然后复制 SAS token ,并将其附加到 URL。那么新的网址如下所示:https://myaccount.blob.core.windows.net/mycontainer/myblockblob?sv=2019-12-12&ss=b&srt=coxxxx

接下来,在 postman 中粘贴新网址。在 header 中,您可以删除 Authorization 字段。

测试结果如下:

enter image description here

关于azure - 如何使用 Postman 将文件上传到 Azure Blob 存储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64965498/

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