示例#1
0
文件: saws.go 项目: jamesunger/saws
func makeBucket(client *s3.S3, bucket *string) error {
	cbi := &s3.CreateBucketInput{Bucket: bucket}
	_, err := client.CreateBucket(cbi)
	if err != nil {
		return err
	}

	return nil
}
示例#2
0
文件: aws.go 项目: sigsegvat/syncaws
func createBucket(bucket string, s3serv *s3.S3) {

	if resp, err := s3serv.ListBuckets(nil); err == nil {
		for _, b := range resp.Buckets {
			if *b.Name == bucket {
				return
			}
		}

		if resp, err := s3serv.CreateBucket(&s3.CreateBucketInput{
			Bucket: aws.String(bucket)}); err == nil {
		} else {
			fmt.Println(err, resp)
		}

	}
}
示例#3
0
// CreateBucket creates a new bucket in the S3 API compatible storage or
// return an error in case the bucket already exists
func CreateBucket(svc *s3.S3, bucketName string) error {
	_, err := svc.CreateBucket(&s3.CreateBucketInput{
		Bucket: aws.String(bucketName),
		ACL:    ACLPublicRead,
	})

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			if awsErr.Code() == "409" {
				return nil
			}
		}

		return err
	}

	return nil
}