storage

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) Open added in v1.1.3

func (s *LocalStorage) Open(filePath string) (io.ReadCloser, error)

Open returns a reader for the stored file so maintenance jobs read back through the interface instead of sniffing the driver. Relative paths resolve against baseDir like Delete does.

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) Open added in v1.1.3

func (s *S3Storage) Open(filePath string) (io.ReadCloser, error)

Open returns a reader for the stored object so maintenance jobs read back through the interface instead of sniffing the driver.

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
	Open(filePath string) (io.ReadCloser, error)
}

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