Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface {
Put(path string, content io.Reader) (string, error)
Get(path string) (io.ReadCloser, error)
Delete(path string) error
URL(path string) string
}
Driver defines the interface for file storage backends.
type LocalDriver ¶
type LocalDriver struct {
BasePath string // e.g. "storage/uploads"
BaseURL string // e.g. "/uploads"
}
LocalDriver stores files on the local filesystem.
func (*LocalDriver) Delete ¶
func (d *LocalDriver) Delete(path string) error
Delete removes the file at the given path.
func (*LocalDriver) Get ¶
func (d *LocalDriver) Get(path string) (io.ReadCloser, error)
Get opens the file at the given path and returns an io.ReadCloser.
func (*LocalDriver) Put ¶
Put writes content to the given path under BasePath. Intermediate directories are created automatically.
func (*LocalDriver) URL ¶
func (d *LocalDriver) URL(path string) string
URL returns the public URL for the given path.
type S3Driver ¶
type S3Driver struct {
Client *s3.Client
Bucket string
Region string
Endpoint string // optional custom endpoint for S3-compatible services
}
S3Driver stores files in an Amazon S3 (or compatible) bucket.
func NewS3Driver ¶
NewS3Driver creates an S3Driver from environment variables.
Required env vars: S3_BUCKET, S3_REGION, S3_KEY, S3_SECRET. Optional: S3_ENDPOINT (for MinIO, DigitalOcean Spaces, etc.).
func (*S3Driver) Get ¶
func (d *S3Driver) Get(path string) (io.ReadCloser, error)
Get retrieves an object from S3 and returns its body as io.ReadCloser.