created media storage package + interface
This commit is contained in:
parent
218e7d652f
commit
1a67c02e00
3 changed files with 102 additions and 0 deletions
35
internal/mediaStorage/handler.go
Normal file
35
internal/mediaStorage/handler.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue