hpds_control_center/internal/minio/index.go

31 lines
579 B
Go
Raw Normal View History

2023-03-23 15:58:12 +08:00
package minio
import (
"git.hpds.cc/Component/logging"
"github.com/minio/minio-go"
)
type MinClient struct {
Client *minio.Client
Logger *logging.Logger
}
func NewClient(ak, sak, ep string, useSSL bool, logger *logging.Logger) *MinClient {
client, err := minio.New(ep, ak, sak, useSSL)
if err != nil {
return nil
}
return &MinClient{
Client: client,
Logger: logger,
}
}
func (cli *MinClient) UploadObject(fn, dst, bucket string) error {
_, err := cli.Client.FPutObject(bucket, dst, fn, minio.PutObjectOptions{})
if err != nil {
return err
}
return nil
}