我正在尝试将图像文件上传到亚马逊 s3。设置如下:
Web 服务器:golang
前端:用于测试的简单html表单
参考本文档:http : //docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html
我参考了上面文档中提供的示例并尝试了这个:http :
//play.golang.org/p/3zn5fSDasK
package main
import "fmt"
import "encoding/base64"
func main() {
bytePolicy := []byte(`{
"expiration": "2013-08-06T12:00:00.000Z",
"conditions": [
{"bucket": "examplebucket"},
["starts-with", "$key", "user/user1/"],
{"acl": "public-read"},
{"success_action_redirect": "http://acl6.s3.amazonaws.com/successful_upload.html"},
["starts-with", "$Content-Type", "image/"],
{"x-amz-meta-uuid": "14365123651274"},
["starts-with", "$x-amz-meta-tag", ""],
{"x-amz-credential":"AKIAIOSFODNN7EXAMPLE/20130806/us-east-1/s3/aws4_request"},
{"x-amz-algorithm": "AWS4-HMAC-SHA256"},
{"x-amz-date": "20130806T000000Z" }
]
}`)
fmt.Println(base64.StdEncoding.EncodeToString(bytePolicy))
}
为什么我的 base64 编码策略与亚马逊的策略不匹配?
HUH函数
相关分类