-
Notifications
You must be signed in to change notification settings - Fork 5
/
new_minio.go
45 lines (41 loc) · 1.32 KB
/
new_minio.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package example
import (
"fmt"
"os"
minio "go.beyondstorage.io/services/minio"
"go.beyondstorage.io/v5/pairs"
"go.beyondstorage.io/v5/services"
"go.beyondstorage.io/v5/types"
)
func NewMinio() (types.Storager, error) {
return minio.NewStorager(
// credential: https://beyondstorage.io/docs/go-storage/pairs/credential
//
// Credential could be fetched from service's console.
//
// Example Value: hmac:access_key_id:secret_access_key
pairs.WithCredential(os.Getenv("STORAGE_MINIO_CREDENTIAL")),
// endpoint: https://beyondstorage.io/docs/go-storage/pairs/endpoint
//
// Example Value: https:host:port
pairs.WithEndpoint(os.Getenv("STORAGE_MINIO_ENDPOINT")),
// name: https://beyondstorage.io/docs/go-storage/pairs/name
//
// name is the bucket name.
pairs.WithName(os.Getenv("STORAGE_MINIO_NAME")),
// work_dir: https://beyondstorage.io/docs/go-storage/pairs/work_dir
//
// Relative operations will be based on this WorkDir.
pairs.WithWorkDir(os.Getenv("STORAGE_MINIO_WORKDIR")),
)
}
func NewMinioFromString() (types.Storager, error) {
str := fmt.Sprintf(
"minio://%s%s?credential=%s&endpoint=%s",
os.Getenv("STORAGE_MINIO_NAME"),
os.Getenv("STORAGE_MINIO_WORKDIR"),
os.Getenv("STORAGE_MINIO_CREDENTIAL"),
os.Getenv("STORAGE_MINIO_ENDPOINT"),
)
return services.NewStoragerFromString(str)
}