示例#1
0
文件: s3upload.go 项目: hoysoft/JexGO
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
文件: main.go 项目: justinwalz/ss3
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
}