當前位置: 首頁>>代碼示例>>Golang>>正文


Golang s3.S3類代碼示例

本文整理匯總了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())
	}
}
開發者ID:ninefive,項目名稱:confd,代碼行數:7,代碼來源:host_style_bucket_test.go

示例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
}
開發者ID:kloudsio,項目名稱:rancher-compose,代碼行數:9,代碼來源:s3_uploader.go

示例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
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:10,代碼來源:s3_uploader.go

示例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
}
開發者ID:kloudsio,項目名稱:rancher-compose,代碼行數:14,代碼來源:s3_uploader.go

示例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
}
開發者ID:johannesboyne,項目名稱:boltbackup,代碼行數:21,代碼來源:boltbackup.go


注:本文中的github.com/awslabs/aws-sdk-go/service/s3.S3類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。