Documentation
¶
Index ¶
- type AttachmentMetadata
- type Config
- type Driver
- type LocalDriver
- func (d *LocalDriver) Close() error
- func (d *LocalDriver) Delete(ctx context.Context, storageKey string) error
- func (d *LocalDriver) Download(ctx context.Context, storageKey string) (io.ReadCloser, error)
- func (d *LocalDriver) GetMetadata(ctx context.Context, storageKey string) (*AttachmentMetadata, error)
- func (d *LocalDriver) GetSignedURL(ctx context.Context, storageKey string, expiration time.Duration) (string, error)
- func (d *LocalDriver) Name() string
- func (d *LocalDriver) Upload(ctx context.Context, name, mimeType string, content io.Reader) (*AttachmentMetadata, error)
- type S3Driver
- func (d *S3Driver) Close() error
- func (d *S3Driver) Delete(ctx context.Context, storageKey string) error
- func (d *S3Driver) Download(ctx context.Context, storageKey string) (io.ReadCloser, error)
- func (d *S3Driver) GetMetadata(ctx context.Context, storageKey string) (*AttachmentMetadata, error)
- func (d *S3Driver) GetSignedURL(ctx context.Context, storageKey string, expiration time.Duration) (string, error)
- func (d *S3Driver) Name() string
- func (d *S3Driver) Upload(ctx context.Context, name, mimeType string, content io.Reader) (*AttachmentMetadata, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttachmentMetadata ¶
type AttachmentMetadata struct {
ID string // Unique identifier (UUID)
Name string // Original filename
MimeType string // MIME type
Size int64 // Size in bytes
StorageKey string // Storage backend key
StorageURI string // Full URI for retrieval
UploadedAt time.Time // Upload timestamp
}
AttachmentMetadata contains metadata about a stored attachment
type Config ¶
type Config struct {
Driver string // "local", "s3", "gcs", "minio"
// Local filesystem config
LocalBasePath string // e.g., "/data/artifacts"
LocalBaseURL string // e.g., "http://localhost:8080/attachments"
// S3-compatible config
S3Endpoint string // AWS endpoint or MinIO URL
S3Region string // AWS region
S3Bucket string // Bucket name
S3AccessKeyID string
S3SecretAccessKey string
S3UsePathStyle bool // For MinIO compatibility
S3PublicURL string // Base URL for public access (optional)
}
Config holds storage driver configuration
type Driver ¶
type Driver interface {
// Upload stores an attachment and returns metadata
Upload(ctx context.Context, name, mimeType string, content io.Reader) (*AttachmentMetadata, error)
// Download retrieves an attachment by storage key
Download(ctx context.Context, storageKey string) (io.ReadCloser, error)
// GetMetadata retrieves metadata for an attachment
GetMetadata(ctx context.Context, storageKey string) (*AttachmentMetadata, error)
// Delete removes an attachment (for cleanup)
Delete(ctx context.Context, storageKey string) error
// GetSignedURL generates a time-limited direct access URL (for cloud storage)
GetSignedURL(ctx context.Context, storageKey string, expiration time.Duration) (string, error)
// Name returns the driver name (e.g., "local", "s3")
Name() string
// Close cleans up resources
Close() error
}
Driver defines the interface for attachment storage backends
type LocalDriver ¶
type LocalDriver struct {
// contains filtered or unexported fields
}
LocalDriver implements storage.Driver for local filesystem storage
func NewLocalDriver ¶
func NewLocalDriver(cfg Config, logger *slog.Logger) (*LocalDriver, error)
NewLocalDriver creates a new local filesystem storage driver
func (*LocalDriver) Close ¶
func (d *LocalDriver) Close() error
Close cleans up resources (no-op for local driver)
func (*LocalDriver) Delete ¶
func (d *LocalDriver) Delete(ctx context.Context, storageKey string) error
Delete removes an attachment from the local filesystem
func (*LocalDriver) Download ¶
func (d *LocalDriver) Download(ctx context.Context, storageKey string) (io.ReadCloser, error)
Download retrieves an attachment from the local filesystem
func (*LocalDriver) GetMetadata ¶
func (d *LocalDriver) GetMetadata(ctx context.Context, storageKey string) (*AttachmentMetadata, error)
GetMetadata retrieves metadata for an attachment
func (*LocalDriver) GetSignedURL ¶
func (d *LocalDriver) GetSignedURL(ctx context.Context, storageKey string, expiration time.Duration) (string, error)
GetSignedURL is not supported for local storage (returns the public URL)
func (*LocalDriver) Upload ¶
func (d *LocalDriver) Upload(ctx context.Context, name, mimeType string, content io.Reader) (*AttachmentMetadata, error)
Upload stores an attachment to the local filesystem
type S3Driver ¶
type S3Driver struct {
// contains filtered or unexported fields
}
S3Driver implements storage.Driver for S3-compatible storage
func NewS3Driver ¶
NewS3Driver creates a new S3 storage driver
func (*S3Driver) GetMetadata ¶
GetMetadata retrieves metadata for an attachment from S3