29 lines
537 B
Go
29 lines
537 B
Go
![]() |
package minio_initialize
|
||
|
|
||
|
import (
|
||
|
"github.com/minio/minio-go/v7"
|
||
|
"github.com/minio/minio-go/v7/pkg/credentials"
|
||
|
)
|
||
|
|
||
|
type MinioInitialize struct {
|
||
|
S3Endpoint string
|
||
|
S3AccessKey string
|
||
|
S3SecretKey string
|
||
|
S3Token string
|
||
|
IsProd bool
|
||
|
}
|
||
|
|
||
|
func Minio(cfg MinioInitialize) (*minio.Client, error) {
|
||
|
conn, err := minio.New(cfg.S3Endpoint,
|
||
|
&minio.Options{
|
||
|
Creds: credentials.NewStaticV4(cfg.S3AccessKey, cfg.S3SecretKey, cfg.S3Token),
|
||
|
Secure: cfg.IsProd,
|
||
|
},
|
||
|
)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return conn, nil
|
||
|
}
|