feat: CI/CD pipeline + Learning/Medicine/Travel services
- Add Gitea Actions workflow for automated build & deploy - Add K8s manifests: webui, travel-svc, medicine-svc, sandbox-svc - Update kustomization for localhost:5000 registry - Add ingress for gooseek.ru and api.gooseek.ru - Learning cabinet with onboarding, courses, sandbox integration - Medicine service with symptom analysis and doctor matching - Travel service with itinerary planning - Server setup scripts (NVIDIA/CUDA, K3s, Gitea runner) Made-with: Cursor
This commit is contained in:
@@ -20,11 +20,13 @@ type MinioConfig struct {
|
||||
SecretKey string
|
||||
Bucket string
|
||||
UseSSL bool
|
||||
PublicURL string
|
||||
}
|
||||
|
||||
type MinioStorage struct {
|
||||
client *minio.Client
|
||||
bucket string
|
||||
client *minio.Client
|
||||
bucket string
|
||||
publicURL string
|
||||
}
|
||||
|
||||
type UploadResult struct {
|
||||
@@ -57,11 +59,23 @@ func NewMinioStorage(cfg MinioConfig) (*MinioStorage, error) {
|
||||
}
|
||||
|
||||
return &MinioStorage{
|
||||
client: client,
|
||||
bucket: cfg.Bucket,
|
||||
client: client,
|
||||
bucket: cfg.Bucket,
|
||||
publicURL: strings.TrimRight(cfg.PublicURL, "/"),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *MinioStorage) GetPublicURL(key string) string {
|
||||
if s.publicURL != "" {
|
||||
return s.publicURL + "/" + s.bucket + "/" + key
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (s *MinioStorage) Bucket() string {
|
||||
return s.bucket
|
||||
}
|
||||
|
||||
func (s *MinioStorage) Upload(ctx context.Context, reader io.Reader, size int64, filename, contentType string) (*UploadResult, error) {
|
||||
ext := filepath.Ext(filename)
|
||||
key := generateStorageKey(ext)
|
||||
@@ -83,6 +97,25 @@ func (s *MinioStorage) Upload(ctx context.Context, reader io.Reader, size int64,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *MinioStorage) UploadWithKey(ctx context.Context, key string, reader io.Reader, size int64, contentType string) (*UploadResult, error) {
|
||||
opts := minio.PutObjectOptions{
|
||||
ContentType: contentType,
|
||||
CacheControl: "public, max-age=2592000",
|
||||
}
|
||||
|
||||
info, err := s.client.PutObject(ctx, s.bucket, key, reader, size, opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to upload file: %w", err)
|
||||
}
|
||||
|
||||
return &UploadResult{
|
||||
Key: key,
|
||||
Bucket: s.bucket,
|
||||
Size: info.Size,
|
||||
ETag: info.ETag,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *MinioStorage) UploadUserFile(ctx context.Context, userID string, reader io.Reader, size int64, filename, contentType string) (*UploadResult, error) {
|
||||
ext := filepath.Ext(filename)
|
||||
key := fmt.Sprintf("users/%s/%s%s", userID, uuid.New().String(), ext)
|
||||
|
||||
Reference in New Issue
Block a user