From 81bcd86304a1cea9b56db4ae7566336c3dcbe378 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Thu, 13 Jul 2023 17:10:48 +0800 Subject: [PATCH] fix: minio auto make bucket --- pkg/common/db/s3/minio/minio.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/common/db/s3/minio/minio.go b/pkg/common/db/s3/minio/minio.go index 367cbe8a8..851464ce7 100644 --- a/pkg/common/db/s3/minio/minio.go +++ b/pkg/common/db/s3/minio/minio.go @@ -40,6 +40,15 @@ func NewMinio() (s3.Interface, error) { if err != nil { return nil, err } + exists, err := client.BucketExists(context.Background(), conf.Bucket) + if err != nil { + return nil, err + } + if !exists { + if err := client.MakeBucket(context.Background(), conf.Bucket, minio.MakeBucketOptions{}); err != nil { + return nil, err + } + } return &Minio{ bucket: conf.Bucket, bucketURL: conf.Endpoint + "/" + conf.Bucket + "/",