From 5c50ab7055c5fb269b197c6d6d23a1108bd17ffe Mon Sep 17 00:00:00 2001 From: Marin Ivanov Date: Sun, 14 Aug 2022 20:03:26 +0300 Subject: Wire Minio client --- fs.go | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'fs.go') diff --git a/fs.go b/fs.go index 8856cfe..74f0273 100644 --- a/fs.go +++ b/fs.go @@ -3,8 +3,30 @@ package s3 import ( "os" "time" + + "github.com/minio/minio-go/v7" + "github.com/minio/minio-go/v7/pkg/credentials" ) +type Fs struct { + client *minio.Client +} + +func NewFs(endpoint, accessKeyID, secretAccessKey string, useSSL bool) (*Fs, error) { + // Initialize minio client object. + client, err := minio.New(endpoint, &minio.Options{ + Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), + Secure: useSSL, + }) + if err != nil { + return nil, err + } + + return &Fs{ + client: client, + }, nil +} + // Create creates a file in the filesystem, returning the file and an // error, if any happens. func (fs *Fs) Create(name string) (File, error) { @@ -75,10 +97,3 @@ func (fs *Fs) Chown(name string, uid, gid int) error { func (fs *Fs) Chtimes(name string, atime time.Time, mtime time.Time) error { panic("not implemented") } - -type Fs struct { -} - -func NewFs(url string) *Fs { - return &Fs{} -} -- cgit v1.2.3