Feat: finish object storage
This commit is contained in:
@@ -1,4 +1,36 @@
|
||||
package implements
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
type MinIOObjectStorage struct {
|
||||
mc *minio.Client
|
||||
}
|
||||
|
||||
func NewMinIOObjectStorage(mc *minio.Client) *MinIOObjectStorage {
|
||||
return &MinIOObjectStorage{mc: mc}
|
||||
}
|
||||
|
||||
func (self *MinIOObjectStorage) PutImage(
|
||||
ctx context.Context,
|
||||
name string,
|
||||
r io.Reader,
|
||||
size int64,
|
||||
) error {
|
||||
_, err := self.mc.PutObject(ctx,
|
||||
viper.GetString("minio-bucket"), name, r, size, minio.PutObjectOptions{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *MinIOObjectStorage) GetImage(
|
||||
ctx context.Context,
|
||||
name string,
|
||||
) (io.Reader, error) {
|
||||
return self.mc.GetObject(ctx,
|
||||
viper.GetString("minio-bucket"), name, minio.GetObjectOptions{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user