Documentation
¶
Overview ¶
Package media defines the files the media library holds.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConflict = errors.New("media: conflicting update")
ErrConflict reports that the media item changed after the update was prepared.
var ErrInvalidAuthor = errors.New("media: invalid author")
ErrInvalidAuthor reports that a media item carries no author.
var ErrInvalidFile = errors.New("media: invalid file")
ErrInvalidFile reports that a media item names no stored file.
var ErrInvalidMime = errors.New("media: invalid mime type")
ErrInvalidMime reports that a media item carries no content type.
var ErrInvalidType = errors.New("media: invalid type")
ErrInvalidType reports that a media kind is not one the library tells apart.
var ErrNotFound = errors.New("media: not found")
ErrNotFound reports that no media item exists for the requested ID.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
Filter narrows a media listing to the type, content type prefixes and search it carries.
type Media ¶
type Media struct {
ID int64
Type Type
File string
Title string
AltText string
Caption string
Description string
MimeType string
Width int
Height int
Filesize int64
Sizes RenditionMap
AuthorID uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
}
Media is a stored upload with the descriptions the editor reads.
type Rendition ¶
type Rendition struct {
File string `json:"file"`
Width int `json:"width"`
Height int `json:"height"`
MimeType string `json:"mime_type"`
Filesize int64 `json:"filesize"`
}
Rendition is one derived copy of an image bounded to a size.
type RenditionMap ¶
RenditionMap holds a media item's renditions keyed by size slug.
type Store ¶
type Store interface {
Create(ctx context.Context, m Media) (Media, error)
ByID(ctx context.Context, id int64) (Media, error)
ByIDs(ctx context.Context, ids []int64) ([]Media, error)
List(ctx context.Context, f Filter) ([]Media, int, error)
Update(ctx context.Context, m Media, expectedUpdatedAt time.Time) (Media, error)
Delete(ctx context.Context, id int64) (Media, error)
}
Store persists the media library.