Пример #1
0
func (s *S3Config) Bucket(client *s3.S3) (*s3.Bucket, error) {
	b := client.Bucket(s.BucketName)
	resp, err := client.ListBuckets()
	if err != nil {
		return b, err
	}
	if bucketOfName(resp.Buckets, s.BucketName) == nil {
		err = b.PutBucket(s3.ACL(s.Acl))
		if err != nil {
			return b, err
		}
	}
	return b, nil
}
Пример #2
0
func listBuckets(client *s3.S3, match string) error {
	resp, err := client.ListBuckets()
	if err != nil {
		return err
	}

	for _, bucket := range resp.Buckets {
		if len(match) > 0 {
			if strings.HasPrefix(bucket.Name, match) {
				fmt.Printf("%s\n", bucket.Name)
			}
		} else {
			fmt.Printf("%s\n", bucket.Name)
		}
	}

	return nil
}