跳转至

创建桶

MakeBucket(ctx context.Context, bucketName string, opts MakeBucketOptions)

创建新的存储桶。

参数

参数 类型 描述
ctx context.Context 自定义上下文,用于超时或取消调用
bucketName string 存储桶的名称
opts minio.MakeBucketOptions 存储桶选项,例如存储桶创建的区域。默认值为 us-east-1。其他有效值如下所示。注意:与 minio 服务器一起使用时,请使用其配置文件中指定的区域(默认为 us-east-1)。

示例

// Create a bucket at region 'us-east-1' with object locking enabled.
err = minioClient.MakeBucket(context.Background(), "mybucket", minio.MakeBucketOptions{Region: "us-east-1", ObjectLocking: true})
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println("Successfully created mybucket.")