Documentation
¶
Overview ¶
Package media handles media for the posts
Index ¶
- Variables
- func GenerateMediaLists(mediaList []Media) ([]string, []string)
- func IdToCacheKey(idHex string) string
- type Core
- func (c *Core) Create(ctx context.Context, newMedia NewMedia) (MediaData, error)
- func (c *Core) CreateMultiple(ctx context.Context, newMediaList []NewMedia) ([]MediaData, error)
- func (c *Core) Delete(ctx context.Context, media Media) error
- func (c *Core) DeleteByID(ctx context.Context, mediaID string) error
- func (c *Core) ParseMedia(r *http.Request) (NewMedia, error)
- func (c *Core) ParseMultipleMedia(r *http.Request) ([]NewMedia, error)
- func (c *Core) QueryByID(ctx context.Context, mediaID string) (Media, error)
- func (c *Core) QueryByIDs(ctx context.Context, mediaIDs []string) ([]Media, error)
- type Media
- type MediaData
- type NewMedia
- type Storer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("media not found") ErrUserNotOwner = errors.New("user does not own the media") )
Set of error variables for CRUD operations.
Functions ¶
func GenerateMediaLists ¶
GenerateMediaLists creates lists of media names and URLs from a slice of Media
func IdToCacheKey ¶
Types ¶
type Core ¶
type Core struct {
MaxFileSizeMb int64
// contains filtered or unexported fields
}
Core manages the set of APIs for media access.
func NewCore ¶
func NewCore(storer Storer, cacheStorer cachestore.CacheStore, userStore user.Storer) *Core
func (*Core) CreateMultiple ¶
func (*Core) ParseMedia ¶
ParseMedia function is utility function that helps handlers to parse media from http request
func (*Core) ParseMultipleMedia ¶
type Media ¶
type Media struct {
ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
OwnerID primitive.ObjectID `json:"owner_id,omitempty"`
Filename string `json:"name"`
Length int64 `json:"length"`
FileBytes []byte `json:"fileBytes"`
}
func (Media) CacheExpiration ¶
type MediaData ¶
func MapToMultiple ¶
type Storer ¶
type Storer interface {
Create(ctx context.Context, media Media) (Media, error)
CreateMultiple(ctx context.Context, media []Media) ([]Media, error)
Update(ctx context.Context, media Media) (Media, error)
Delete(ctx context.Context, media Media) error
DeleteByID(ctx context.Context, mediaID string) error
QueryByID(ctx context.Context, mediaID string) (Media, error)
QueryByIDs(ctx context.Context, mediaIDs []string) ([]Media, error)
}
Click to show internal directories.
Click to hide internal directories.