answerer/dal/dal.go

33 lines
677 B
Go
Raw Normal View History

2024-02-19 18:27:12 +00:00
package dal
import (
"context"
"fmt"
"github.com/minio/minio-go/v7"
"io"
)
const (
2024-05-29 22:40:26 +00:00
bucket = "3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b"
2024-02-19 18:27:12 +00:00
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 {
2024-05-29 22:40:26 +00:00
if _, err := s.client.PutObject(ctx, bucket, bucketAnswers + "/" +fmt.Sprintf("%s/%d/%s", quizId, question, name), file, size,
2024-02-19 18:27:12 +00:00
minio.PutObjectOptions{}); err != nil {
return err
}
return nil
}