media

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VariantOriginal = "original"
	VariantContent  = "content"
	VariantThumb    = "thumb"
)

Variables

View Source
var ErrInvalidImage = errors.New("invalid image")
View Source
var ErrTooLarge = errors.New("upload too large")

Functions

This section is empty.

Types

type Manager

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

Manager handles filesystem operations for assets.

func NewManager

func NewManager(root string, variants VariantConfig) *Manager

func (*Manager) IsWritable

func (m *Manager) IsWritable() error

func (*Manager) PathForVariant

func (m *Manager) PathForVariant(sha, variant, ext string) string

func (*Manager) Save

func (m *Manager) Save(ctx context.Context, r io.Reader, filename string, maxBytes int64, maxPixels int) (*SaveResult, error)

Save streams the upload to disk, computes SHA-256, validates pixels, and generates WebP variants.

type SaveResult

type SaveResult struct {
	SHA256 string
	Bytes  int64
	Mime   string
	Width  int
	Height int
	Ext    string
}

SaveResult describes a validated, persisted upload.

type VariantConfig added in v0.2.0

type VariantConfig struct {
	ContentMaxWidth int
	ThumbMaxWidth   int
}

VariantConfig controls the dimensions of generated media variants.

Jump to

Keyboard shortcuts

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