我不明白出了什么问题((
我有几个问题:
1)如果我必须将任何政策放到我的S3桶中。如果是 - 您能否帮助我了解如何制定政策
2)我有这个政策:
{
"expiration": "2016-11-07T20:18:13.326Z",
"conditions": [
{
"acl": "public"
},
{
"bucket": "bucket_name"
},
{
"Content-Type": "text/plain"
},
{
"success_action_status": "200"
},
{
"key": "c94d36ee-19eb-49e8-ac30-760b29982391.txt"
},
{
"x-amz-meta-qqfilename": "111.txt"
}
]
}
所以在我的C#代码中我做了:
private string GeneratePolicy()
{
byte[] bytesToEncode = File.ReadAllBytes("s3policy.txt");
string encodedText = Convert.ToBase64String(bytesToEncode);
return encodedText;
}
static string GetSig(string policyStr)
{
string b64Policy = Convert.ToBase64String(Encoding.ASCII.GetBytes(policyStr));
byte[] b64Key = Encoding.ASCII.GetBytes("HERE-IS-MY-SECRET-KEY");
HMACSHA1 hmacSha1 = new HMACSHA1(b64Key);
string singPolicy = Convert.ToBase64String(hmacSha1.ComputeHash(Encoding.ASCII.GetBytes(b64Policy)));
return singPolicy;
}
但是不起作用(
知道为什么吗?
谢谢