storage

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalStorage

type LocalStorage struct {
	// contains filtered or unexported fields
}

LocalStorage implements the Storage interface for local file storage

func NewLocalStorage

func NewLocalStorage(baseDir string, urlPathPrefix string) *LocalStorage

NewLocalStorage creates a new local file storage rooted at baseDir and served under the given URL path prefix (e.g. "/uploads/media/")

func (*LocalStorage) Delete

func (s *LocalStorage) Delete(filePath string) error

Delete deletes a file from the local storage. If filePath is relative, it is resolved against baseDir.

func (*LocalStorage) GetURL

func (s *LocalStorage) GetURL(filePath string) string

GetURL returns the relative URL path for a file. Local uploads are always served by this same process (the /uploads/ file server is mounted only when the local driver is active), so a root-relative URL keeps working behind reverse proxies and HTTPS without baking host/port into stored data.

func (*LocalStorage) Save

func (s *LocalStorage) Save(filename string, reader io.Reader) (string, error)

Save saves a file to the local storage

type S3Options

type S3Options struct {
	Endpoint        string
	Region          string
	Bucket          string
	AccessKeyID     string
	SecretAccessKey string
	UsePathStyle    bool
	PublicBaseURL   string
	KeyPrefix       string
	HTTPClient      *http.Client
	Retryer         aws.Retryer
}

S3Options holds the configuration for an S3-compatible storage backend. AWS S3 and MinIO both speak the S3 API — the same client serves either: leave Endpoint empty for AWS, or set it (e.g. "http://minio:9000") for MinIO.

type S3Storage

type S3Storage struct {
	// contains filtered or unexported fields
}

S3Storage implements the Storage interface for S3-compatible object storage

func NewS3Storage

func NewS3Storage(opts S3Options) (*S3Storage, error)

NewS3Storage creates an S3-compatible storage backend (AWS S3 or MinIO)

func (*S3Storage) Delete

func (s *S3Storage) Delete(filePath string) error

Delete removes an object from the bucket

func (*S3Storage) GetURL

func (s *S3Storage) GetURL(filePath string) string

GetURL returns the public URL for a stored file

func (*S3Storage) Save

func (s *S3Storage) Save(filename string, reader io.Reader) (string, error)

Save uploads a file to the bucket under the key prefix + filename

type Storage

type Storage interface {
	Save(filename string, reader io.Reader) (string, error)
	Delete(filePath string) error
	GetURL(filePath string) string
}

Storage defines the interface for file storage operations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL