获取桶列表
ListBuckets(ctx context.Context) ([]BucketInfo, error)
列出所有存储桶。
参数
参数 |
类型 |
描述 |
ctx |
context.Context |
自定义上下文,用于超时或取消调用 |
bucketList |
[]minio.BucketInfo |
所有存储桶的列表 |
opts |
minio.MakeBucketOptions |
存储桶选项,例如存储桶创建的区域。默认值为 us-east-1。其他有效值如下所示。注意:与 minio 服务器一起使用时,请使用其配置文件中指定的区域(默认为 us-east-1)。 |
minio.BucketInfo
参数 |
类型 |
描述 |
bucket.Name |
string |
存储桶的名称 |
bucket.CreationDate |
time.Time |
存储桶创建的日期 |
示例
buckets, err := minioClient.ListBuckets(context.Background())
if err != nil {
fmt.Println(err)
return
}
for _, bucket := range buckets {
fmt.Println(bucket)
}