本文整理汇总了Golang中github.com/goamz/goamz/s3.S3类的典型用法代码示例。如果您正苦于以下问题:Golang S3类的具体用法?Golang S3怎么用?Golang S3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了S3类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testBucket
func testBucket(s *s3.S3) *s3.Bucket {
// Watch out! If this function is corrupted and made to match with something
// people own, killBucket will happily remove *everything* inside the bucket.
key := s.Auth.AccessKey
if len(key) >= 8 {
key = s.Auth.AccessKey[:8]
}
return s.Bucket(fmt.Sprintf("goamz-%s-%s", s.Region.Name, key))
}
示例2: NewS3Session
func NewS3Session(auth *aws.Auth, region aws.Region) *s3.S3 {
var s3Session *s3.S3
cert := x509.Certificate{}
// go's systemVerify panics with no verify options set
// TODO: EVG-483
if runtime.GOOS == "windows" {
s3Session = s3.New(*auth, region)
s3Session.ReadTimeout = S3ReadTimeout
s3Session.WriteTimeout = S3WriteTimeout
s3Session.ConnectTimeout = S3ConnectTimeout
return s3Session
}
// no verify options so system root ca will be used
_, err := cert.Verify(x509.VerifyOptions{})
rootsError := x509.SystemRootsError{}
if err != nil && err.Error() == rootsError.Error() {
// create a Transport which includes our TLSConfig with InsecureSkipVerify
// and client timeouts.
tlsConfig := tls.Config{InsecureSkipVerify: true}
tr := http.Transport{
TLSClientConfig: &tlsConfig}
// add the Transport to our http client
client := &http.Client{Transport: &tr}
s3Session = s3.New(*auth, region, client)
} else {
s3Session = s3.New(*auth, region)
}
s3Session.ReadTimeout = S3ReadTimeout
s3Session.WriteTimeout = S3WriteTimeout
s3Session.ConnectTimeout = S3ConnectTimeout
return s3Session
}
示例3: Bucket
// Bucket get bucket of S3 via bucket name.
func Bucket(connection *s3.S3, bucketName string) *s3.Bucket {
return connection.Bucket(bucketName)
}