Example #1
0
func makeBucket(client *s3.S3, bucket *string) error {
	cbi := &s3.CreateBucketInput{Bucket: bucket}
	_, err := client.CreateBucket(cbi)
	if err != nil {
		return err
	}

	return nil
}
Example #2
0
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)
		}

	}
}
Example #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
}