mirror of
https://github.com/multica-ai/multica.git
synced 2026-08-03 19:20:07 +02:00
Adds a streaming read method to the Storage abstraction so callers can pull object bytes without forcing a full in-memory load. S3Storage wraps GetObject; LocalStorage opens the file with path-traversal and sidecar guards. Tests cover happy path, traversal rejection, sidecar rejection, and missing key. Used in the next commit by the attachment-preview proxy endpoint. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
20 lines
648 B
Go
20 lines
648 B
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
)
|
|
|
|
type Storage interface {
|
|
Upload(ctx context.Context, key string, data []byte, contentType string, filename string) (string, error)
|
|
Delete(ctx context.Context, key string)
|
|
DeleteKeys(ctx context.Context, keys []string)
|
|
KeyFromURL(rawURL string) string
|
|
CdnDomain() string
|
|
// GetReader streams an object back to the caller. Used by the attachment
|
|
// preview proxy (GET /api/attachments/{id}/content) to bypass CloudFront
|
|
// CORS and the inline/attachment Content-Disposition decision. Caller
|
|
// must Close the returned reader.
|
|
GetReader(ctx context.Context, key string) (io.ReadCloser, error)
|
|
}
|