// Package storage abstracts photo object storage. Selection follows the // backend's convention (backend/src/lib/storage.ts): S3 when S3_ENDPOINT // and S3_BUCKET are both set, local disk otherwise. Keys are identical on // both backends: galleries///.. package storage import ( "context" "errors" "io" "time" "git.azzamo.net/Michilis/Spanglish/photo-api/internal/config" ) // ErrNoPresign is returned by backends that cannot presign (local disk); // callers then stream the object through the API instead. var ErrNoPresign = errors.New("presigned URLs not supported") type Storage interface { Put(ctx context.Context, key string, r io.Reader, size int64, contentType string) error Open(ctx context.Context, key string) (io.ReadCloser, int64, error) Delete(ctx context.Context, key string) error PresignGet(ctx context.Context, key, downloadFilename, contentType string, expiry time.Duration) (string, error) } func New(cfg config.Config) (Storage, error) { if cfg.S3Enabled() { return newS3(cfg) } return newLocal(cfg.StoragePath) }