Define all repository interfaces in port/repository.go: FileRepo, TagRepo, TagRuleRepo, CategoryRepo, PoolRepo, UserRepo, SessionRepo, ACLRepo, AuditRepo, MimeRepo, and Transactor. Add OffsetParams and PoolFileListParams as shared parameter structs. Define FileStorage interface in port/storage.go with Save, Read, Delete, Thumbnail, and Preview methods. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package port
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// FileStorage abstracts disk (or object-store) operations for file content,
|
|
// thumbnails, and previews.
|
|
type FileStorage interface {
|
|
// Save writes the reader's content to storage and returns the number of
|
|
// bytes written. ext is the file extension without a leading dot (e.g. "jpg").
|
|
Save(ctx context.Context, id uuid.UUID, ext string, r io.Reader) (int64, error)
|
|
|
|
// Read opens the file content for reading. The caller must close the returned
|
|
// ReadCloser.
|
|
Read(ctx context.Context, id uuid.UUID, ext string) (io.ReadCloser, error)
|
|
|
|
// Delete removes the file content from storage.
|
|
Delete(ctx context.Context, id uuid.UUID, ext string) error
|
|
|
|
// Thumbnail opens the pre-generated thumbnail (JPEG). Returns ErrNotFound
|
|
// if the thumbnail has not been generated yet.
|
|
Thumbnail(ctx context.Context, id uuid.UUID) (io.ReadCloser, error)
|
|
|
|
// Preview opens the pre-generated preview image (JPEG). Returns ErrNotFound
|
|
// if the preview has not been generated yet.
|
|
Preview(ctx context.Context, id uuid.UUID) (io.ReadCloser, error)
|
|
}
|