36 lines
665 B
Go
36 lines
665 B
Go
|
|
package mediaStorage
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"github.com/minio/minio-go/v7"
|
||
|
|
"github.com/minio/minio-go/v7/pkg/credentials"
|
||
|
|
log "github.com/sirupsen/logrus"
|
||
|
|
)
|
||
|
|
|
||
|
|
type Handler struct {
|
||
|
|
*Service
|
||
|
|
}
|
||
|
|
|
||
|
|
type Deps struct {
|
||
|
|
Host string
|
||
|
|
Port string
|
||
|
|
User string
|
||
|
|
Password string
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewHandler(deps Deps) *Handler {
|
||
|
|
endpoint := fmt.Sprintf("%s:%s", deps.Host, deps.Port)
|
||
|
|
minioClient, err := minio.New(endpoint, &minio.Options{
|
||
|
|
Creds: credentials.NewStaticV4(deps.User, deps.Password, ""),
|
||
|
|
Secure: false,
|
||
|
|
})
|
||
|
|
|
||
|
|
if err != nil {
|
||
|
|
log.WithError(err).Fatal("Media storage | Failed to create minio client")
|
||
|
|
}
|
||
|
|
|
||
|
|
return &Handler{
|
||
|
|
newService(minioClient),
|
||
|
|
}
|
||
|
|
}
|