Documentation
¶
Overview ¶
Package mediahost validates uploads and owns the media directory.
Index ¶
Constants ¶
const DefaultJPEGQuality = 82
DefaultJPEGQuality is the quality renditions encode at when nothing else applies.
const DefaultMaxSize = 128 << 20
DefaultMaxSize bounds an upload when the library is not given its own cap.
const JPEGQualityKey = "media.jpeg_quality"
JPEGQualityKey names the stored quality renditions encode at.
const MaxJPEGQuality = 100
MaxJPEGQuality is the highest quality renditions may encode at.
Variables ¶
This section is empty.
Functions ¶
func ParseJPEGQuality ¶ added in v0.11.0
ParseJPEGQuality returns the quality the text names, or the reason it is not one.
func ResolveJPEGQuality ¶ added in v0.11.0
ResolveJPEGQuality returns the quality a stored setting names, or the default when it names none.
Types ¶
type Config ¶
type Config struct {
// Dir is the directory uploads land in. Empty refuses every upload.
Dir string
// MaxSize bounds one upload in bytes. Zero applies [DefaultMaxSize].
MaxSize int64
// Settings answers the quality pictures encode at. Nil applies [DefaultJPEGQuality].
Settings Settings
}
Config carries what a library needs to own its directory.
type Error ¶ added in v0.9.0
type Error struct {
// Code names the rule the upload broke, for a client that translates it.
Code string
// Reason names the rule the upload broke, in words fit for an admin screen.
Reason string
// Detail is what went wrong underneath, for the log.
Detail error
// Meta carries the values the message the client shows names.
Meta map[string]any
}
Error reports an upload turned away, carrying the reason an operator reads.
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library owns the media directory uploads land in.