本文整理汇总了Golang中github.com/awslabs/aws-sdk-go/service/s3.S3类的典型用法代码示例。如果您正苦于以下问题:Golang S3类的具体用法?Golang S3怎么用?Golang S3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了S3类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runTests
func runTests(t *testing.T, svc *s3.S3, tests []s3BucketTest) {
for _, test := range tests {
req, _ := svc.ListObjectsRequest(&s3.ListObjectsInput{Bucket: &test.bucket})
req.Build()
assert.Equal(t, test.url, req.HTTPRequest.URL.String())
}
}
示例2: putFile
func putFile(svc *s3.S3, bucket, object string, reader io.ReadSeeker) error {
_, err := svc.PutObject(&s3.PutObjectInput{
Bucket: &bucket,
Key: &object,
Body: reader,
})
return err
}
示例3: putFile
func putFile(svc *s3.S3, bucket, object string, reader io.ReadSeeker) error {
_, err := svc.PutObject(&s3.PutObjectInput{
Bucket: &bucket,
Key: &object,
Body: reader,
ContentType: aws.String("application/tar"),
})
return err
}
示例4: getOrCreateBucket
func getOrCreateBucket(svc *s3.S3, bucketName string) error {
_, err := svc.HeadBucket(&s3.HeadBucketInput{
Bucket: &bucketName,
})
if reqErr, ok := err.(awserr.RequestFailure); ok && reqErr.StatusCode() == 404 {
logrus.Infof("Creating bucket %s", bucketName)
_, err = svc.CreateBucket(&s3.CreateBucketInput{
Bucket: &bucketName,
})
}
return err
}
示例5: Do
func Do(db *bolt.DB, s3Bucket *s3.S3, bucketname string) error {
err := db.View(func(tx *bolt.Tx) error {
var b bytes.Buffer
buffInMem := bufio.NewWriter(&b)
_, err := tx.WriteTo(buffInMem)
backupdate := time.Now()
params := &s3.PutObjectInput{
Bucket: aws.String(bucketname),
Key: aws.String(backupdate.Format("2006_01_02_15-04-05")),
Body: bytes.NewReader(b.Bytes()),
ACL: aws.String("authenticated-read"),
ServerSideEncryption: aws.String("AES256"),
Metadata: &map[string]*string{
"bolt-backup": aws.String(backupdate.Format("2006/01/02/15:04:05")),
},
}
_, err = s3Bucket.PutObject(params)
return err
})
return err
}