mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 06:19:20 +08:00
+33
-4
@@ -16,6 +16,9 @@ package rpcclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"net/url"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
@@ -25,9 +28,10 @@ import (
|
||||
)
|
||||
|
||||
type Third struct {
|
||||
conn grpc.ClientConnInterface
|
||||
Client third.ThirdClient
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
conn grpc.ClientConnInterface
|
||||
Client third.ThirdClient
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
MinioClient *minio.Client
|
||||
}
|
||||
|
||||
func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
|
||||
@@ -36,5 +40,30 @@ func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
|
||||
panic(err)
|
||||
}
|
||||
client := third.NewThirdClient(conn)
|
||||
return &Third{discov: discov, Client: client, conn: conn}
|
||||
minioClient, err := minioInit()
|
||||
return &Third{discov: discov, Client: client, conn: conn, MinioClient: minioClient}
|
||||
}
|
||||
|
||||
func minioInit() (*minio.Client, error) {
|
||||
minioClient := &minio.Client{}
|
||||
var initUrl string
|
||||
initUrl = config.Config.Object.Minio.Endpoint
|
||||
minioUrl, err := url.Parse(initUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
opts := &minio.Options{
|
||||
Creds: credentials.NewStaticV4(config.Config.Object.Minio.AccessKeyID, config.Config.Object.Minio.SecretAccessKey, ""),
|
||||
//Region: config.Config.Credential.Minio.Location,
|
||||
}
|
||||
if minioUrl.Scheme == "http" {
|
||||
opts.Secure = false
|
||||
} else if minioUrl.Scheme == "https" {
|
||||
opts.Secure = true
|
||||
}
|
||||
minioClient, err = minio.New(minioUrl.Host, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return minioClient, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user