Files
mtusi2026lab4/internal/platform/objectstore/objectstore.go
T

33 lines
1.2 KiB
Go

// Package objectstore defines the S3-compatible port used by attachments.
// Metadata never belongs here: PostgreSQL is the source of truth, this package
// only moves bytes and exposes object timestamps for the orphan sweeper.
package objectstore
import (
"context"
"io"
"time"
)
// Object is the provider-neutral view of one stored object.
type Object struct {
Key string
Size int64
ContentType string
LastModified time.Time
Metadata map[string]string
}
// Store is implemented by S3-compatible backends. Put requires a seekable body
// because AWS SigV4 may need to rewind the payload; the proxy upload path always
// passes an *os.File.
type Store interface {
Put(ctx context.Context, key string, body io.ReadSeeker, size int64, contentType string, metadata map[string]string) error
Open(ctx context.Context, key string) (io.ReadCloser, Object, error)
Head(ctx context.Context, key string) (Object, error)
Copy(ctx context.Context, src, dst, contentType string, metadata map[string]string) error
Delete(ctx context.Context, key string) error
List(ctx context.Context, prefix string) ([]Object, error)
PresignPut(ctx context.Context, key string, size int64, ttl time.Duration) (string, time.Time, error)
}