示例#1
0
文件: commands.go 项目: egidijus/s3
func listBuckets(conn s3iface.S3API) error {
	output, err := conn.ListBuckets(nil)
	if err != nil {
		return err
	}
	for _, b := range output.Buckets {
		fmt.Fprintf(out, "s3://%s/\n", *b.Name)
	}
	return nil
}
示例#2
0
文件: commands.go 项目: egidijus/s3
func rmBuckets(conn s3iface.S3API, buckets []string) error {
	for _, name := range buckets {
		bucket, _ := extractBucketPath(name)
		input := s3.DeleteBucketInput{Bucket: aws.String(bucket)}
		_, err := conn.DeleteBucket(&input)
		if err != nil {
			return err
		}
	}
	return nil
}
示例#3
0
文件: commands.go 项目: egidijus/s3
func putBuckets(conn s3iface.S3API, buckets []string) error {
	for _, bucket := range buckets {
		input := s3.CreateBucketInput{
			ACL:    aws.String(acl),
			Bucket: aws.String(bucket),
		}
		_, err := conn.CreateBucket(&input)
		if err != nil {
			return err
		}
	}
	return nil
}
示例#4
0
文件: commands.go 项目: egidijus/s3
func deleteBatch(conn s3iface.S3API, bucket string, batch []*s3.ObjectIdentifier) error {
	if !dryRun {
		deleteRequest := s3.Delete{
			Objects: batch,
		}
		input := s3.DeleteObjectsInput{
			Bucket: aws.String(bucket),
			Delete: &deleteRequest,
		}
		_, err := conn.DeleteObjects(&input)
		return err
	}
	return nil
}