I want to put a text file to a blob container using HttResquestMessage, and I get 403 error(Forbidden). I know that this is a famous problem, and there are a lot of answers about it, but I've searched a lot and couldn't find the problem in my case. Here is my Signature
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"
And this is Authorization generated by SHA256
and Base64
encoding
SharedKey MyStorage:Oy8nB79/KVROzxYCYSF71djhIwYEYS36tgRqyxe6sXY=
This Authorization works for GET request I've tried to get all container names and it succeeded.
My HttpRequestMessage looks like
{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}
What I missed in the request?
Two parameters need adding when putting blob
x-ms-blob-type
is required to be included in HttpRequestMessage header. Content-MD5
is optional, but if you add it in your request header, it should also be included in StringToSign, ie the Signature you mentioned. Any further question, just ask.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.