persona-community-5/pkg/storage/store.go
jordan bd2f591b98
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/manual/woodpecker Pipeline was successful
Initialize project from skeleton template
2026-02-24 07:39:46 +00:00

44 lines
1.4 KiB
Go

// Package storage provides object storage for media files.
// In production, uses GCS. In development (standalone mode), uses in-memory storage.
package storage
import (
"context"
"time"
)
// Store abstracts object storage operations.
type Store interface {
// Upload stores data at the given path and returns its public/signed URL.
Upload(ctx context.Context, path string, data []byte, contentType string) (string, error)
// UploadPresigned returns a presigned URL for direct client-to-storage uploads.
UploadPresigned(ctx context.Context, path string, contentType string) (*PresignedUpload, error)
// GetURL returns a signed or public URL for the object.
GetURL(ctx context.Context, path string) (string, error)
// Delete removes an object.
Delete(ctx context.Context, path string) error
// List returns objects matching the given prefix.
List(ctx context.Context, prefix string) ([]MediaObject, error)
}
// PresignedUpload contains the details for a direct-upload to storage.
type PresignedUpload struct {
URL string `json:"url"`
Headers map[string]string `json:"headers"`
Method string `json:"method"` // "PUT"
Expires time.Time `json:"expires"`
}
// MediaObject represents a stored media file.
type MediaObject struct {
Path string `json:"path"`
URL string `json:"url"`
ContentType string `json:"contentType"`
Size int64 `json:"size"`
CreatedAt time.Time `json:"createdAt"`
}