之前我使用“launchpad.net/goamz/s3” 但对于我的新项目,我正在使用“github.com/goamz/goamz/s3”。 现在桶的put方法有变化,它还有一个参数“选项”
region := aws.USEast2
connection := s3.New(AWSAuth, region)
bucket := connection.Bucket("XXXXX") // change this your bucket name
path := "mypath" // this is the target file and location in S3
//Save image to s3
err = bucket.Put(path,user_content,content_type, s3.ACL("public-read"), options)
以上是我的代码。你能帮我看一下选项中的预期以及如何获得它的价值吗?
答案 0 :(得分:2)
选项在s3.go中定义:
type Options struct {
SSE bool
Meta map[string][]string
ContentEncoding string
CacheControl string
RedirectLocation string
ContentMD5 string
// What else?
// Content-Disposition string
//// The following become headers so they are []strings rather than strings... I think
// x-amz-storage-class []string
}
这些选项已在official S3 api docs中详细记录。
在最简单的情况下,你可以不传递任何东西。例如:
bucket.Put(path,user_content,content_type, s3.ACL("public-read"), s3.Options{})