【发布时间】:2018-10-21 13:02:15
【问题描述】:
我想使用 HttResquestMessage 将文本文件放入 blob 容器,但出现 403 错误(禁止访问)。 我知道这是一个著名的问题,并且有很多关于它的答案,但是我搜索了很多,找不到我的问题。 这是我的签名
PUT\n
\n
\n
11\n
\n
\n
\n
\n
\n
\n
\n
\n
x-ms-blob-type:BlockBlob\n
x-ms-date:Thu, 10 May 2018 16:00:21 GMT\n
x-ms-version:2017-07-29\n
/MyStorage/dbstore/myFolder/test2.txt"
这是SHA256和Base64编码生成的授权
SharedKey MyStorage:Oy8nB79/KVROzxYCYSF71djhIwYEYS36tgRqyxe6sXY=
此授权适用于 GET 请求我已尝试获取所有容器名称并成功。
我的 HttpRequestMessage 看起来像
{Method: PUT, RequestUri:
'http://MyStorage.blob.core.windows.net/dbstore/
myFolder/test2.txt', Version: 1.1, Content:
System.Net.Http.ByteArrayContent, Headers:
{
x-ms-date: Fri, 11 May 2018 06:39:35 GMT
x-ms-version: 2017-07-29
Authorization: SharedKey
storagekaren:Oy8nB79/KVROzxYCYSF71djhIwYEYS36tgRqyxe6sXY=
Content-Length: 11
Content-MD5: CAQ66JnJH0H9GhrLTy+b1w==
}}
Content: {System.Net.Http.ByteArrayContent}
Headers: {x-ms-date: Fri, 11 May 2018 06:39:35 GMT
x-ms-version: 2017-07-29
Authorization: SharedKey
storagekaren:Oy8nB79/KVROzxYCYSF71djhIwYEYS36tgRqyxe6sXY=
}
Method: {PUT}
Properties: Count = 0
RequestUri: {http://MyStorage.blob.core.windows.net/dbstore/myFolder/test2.txt}
Version: {1.1}
我在请求中遗漏了什么?
【问题讨论】:
标签: c# rest azure httprequest azure-blob-storage