-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
client.go
31 lines (27 loc) · 804 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package s3client
import (
"crypto/tls"
"net/http"
"github.com/admpub/nging/v4/application/dbschema"
"github.com/admpub/nging/v4/application/library/s3manager"
minio "github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
)
func Connect(m *dbschema.NgingCloudStorage) (client *minio.Client, err error) {
isSecure := m.Secure == `Y`
options := &minio.Options{
Creds: credentials.NewStaticV4(m.Key, m.Secret, ""),
Secure: isSecure,
Region: m.Region,
}
if isSecure {
options.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
}
client, err = minio.New(m.Endpoint, options)
return
}
func New(m *dbschema.NgingCloudStorage, editableMaxSize int) *s3manager.S3Manager {
return s3manager.New(Connect, m, editableMaxSize)
}