20 lines
713 B
Go
20 lines
713 B
Go
package media
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
)
|
|
|
|
// Storage is the pluggable backend that actually persists uploaded bytes.
|
|
// The service/handler layers never know whether files end up on local disk
|
|
// or in an S3 bucket -- only main.go decides which implementation to wire
|
|
// in, based on MEDIA_STORAGE_DRIVER.
|
|
type Storage interface {
|
|
// Save persists the content under the given key and returns the
|
|
// publicly reachable URL for it.
|
|
Save(ctx context.Context, key string, reader io.Reader, size int64, contentType string) (url string, err error)
|
|
// Delete removes the object identified by key. Deleting a
|
|
// already-removed key must not be treated as an error.
|
|
Delete(ctx context.Context, key string) error
|
|
}
|