common/repository/answer/dal_minio.go

31 lines
709 B
Go
Raw Normal View History

2024-03-28 12:22:54 +00:00
package answer
2024-03-28 11:53:12 +00:00
import (
"context"
"fmt"
"github.com/minio/minio-go/v7"
)
const (
2025-05-19 11:18:41 +00:00
bucket = "3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b"
2024-03-28 11:53:12 +00:00
bucketAnswers = "squizanswer"
)
type StorerAnswer struct {
client *minio.Client
}
func NewAnswerMinio(ctx context.Context, minioClient *minio.Client) (*StorerAnswer, error) {
return &StorerAnswer{
client: minioClient,
}, nil
}
func (s *StorerAnswer) GetAnswerURL(ctx context.Context, quizID string, questionID int64, filename string) (string, error) {
objectName := fmt.Sprintf("%s/%d/%s", quizID, questionID, filename)
2025-05-19 11:18:41 +00:00
url := fmt.Sprintf("https://%s/%s/%s", s.client.EndpointURL().Host, bucket, bucketAnswers+"/"+objectName)
2024-03-28 11:53:12 +00:00
2025-05-19 11:18:41 +00:00
return url, nil
2024-03-28 11:53:12 +00:00
}