33 lines
677 B
Go
33 lines
677 B
Go
package dal
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/minio/minio-go/v7"
|
|
"io"
|
|
)
|
|
|
|
const (
|
|
bucket = "3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b"
|
|
bucketAnswers = "squizanswer"
|
|
)
|
|
|
|
type Storer struct {
|
|
client *minio.Client
|
|
}
|
|
|
|
func New(ctx context.Context, minioClient *minio.Client) (*Storer, error) {
|
|
return &Storer{
|
|
client: minioClient,
|
|
}, nil
|
|
}
|
|
|
|
func (s *Storer) PutAnswer(ctx context.Context, file io.Reader, quizId, name string, question uint64, size int64) error {
|
|
if _, err := s.client.PutObject(ctx, bucket, bucketAnswers + "/" +fmt.Sprintf("%s/%d/%s", quizId, question, name), file, size,
|
|
minio.PutObjectOptions{}); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|