string VERB="PUT";
string Content_MD5="";
string Content_Type = "application/x-www-form-urlencoded";
string Date=DateTime.Now.ToUniversalTime().ToString("r");
string CanonicalizedOSSHeaders="";
string CanonicalizedResource = "/****/oss.txt";
string tem = VERB + "\n"
+ Content_MD5 + "\n"
+ Content_Type + "\n"
+ Date + "\n"
+ CanonicalizedOSSHeaders
+ CanonicalizedResource;
string Signature = Convert.ToBase64String(HmacSha1Sign(
tem, AccessKey_Secret));
string Authorization="OSS " + AccessKey_ID + ":" + Signature;
在计算待加密数据
Signature 值得到的结果和官方的SDK得到的字符串一样,但是提交上传的时候反馈:在 WebClient 请求期间发生异常
提交时的Headers值如下:
myWebClient.Headers.Add("Authorization", Authorization);
myWebClient.Headers.Add("Host", "****.oss-cn-shanghai.aliyuncs.com");
myWebClient.Headers.Add("Cache-control", "no-cache");
myWebClient.Headers.Add("Date", Date);
myWebClient.Headers.Add("Content_MD5", Content_MD5);
myWebClient.Headers.Add("Content-Type", Content_Type);
myWebClient.Headers.Add("CanonicalizedOSSHeaders", CanonicalizedOSSHeaders);
myWebClient.Headers.Add("CanonicalizedResource", CanonicalizedResource);
//发起验证并上传文件
using (Stream postStream = myWebClient.OpenWrite("https://****.oss-cn-shanghai.aliyuncs.com/****/oss.txt", "PUT"))
{
if (postStream.CanWrite)
{
postStream.Write(files, 0, files.Length);
}
}
请问问题是出在哪里呢?