Documentation ¶
Overview ¶
Package media represents media storage abstraction layer. It provides a set of interfaces and helpers to interact with media-storage services.
If package decides to have media files related to model instances it should refer to that library for implementation of media storage list/read/write operations.
Providing Ottemo with a new media storage supposing "InterfaceMediaStorage" implementation with following registration for media package.
Index ¶
Constants ¶
const ( ConstErrorModule = "media" ConstErrorLevel = env.ConstErrorLevelService ConstMediaTypeImage = "image" ConstMediaTypeLink = "link" ConstMediaTypeDocument = "document" )
Package global constants
Variables ¶
This section is empty.
Functions ¶
func OnMediaStorageStart ¶
func OnMediaStorageStart() error
OnMediaStorageStart fires media storage service start event (callback handling)
func RegisterMediaStorage ¶
func RegisterMediaStorage(newEngine InterfaceMediaStorage) error
RegisterMediaStorage registers media storage service in the system
- will cause error if there are couple candidates for that role
func RegisterOnMediaStorageStart ¶
func RegisterOnMediaStorageStart(callback func() error)
RegisterOnMediaStorageStart registers new callback on media storage service start
Types ¶
type InterfaceMediaStorage ¶
type InterfaceMediaStorage interface { GetName() string Load(model string, objID string, mediaType string, mediaName string) ([]byte, error) Save(model string, objID string, mediaType string, mediaName string, mediaData []byte) error Remove(model string, objID string, mediaType string, mediaName string) error ListMedia(model string, objID string, mediaType string) ([]string, error) ListMediaDetail(model string, objID string, mediaType string) ([]map[string]interface{}, error) GetMediaPath(model string, objID string, mediaType string) (string, error) GetAllSizes(model string, objID string, mediaType string) ([]map[string]string, error) GetSizes(model string, objID string, mediaType string, mediaName string) (map[string]string, error) ResizeAllMediaImages() error }
InterfaceMediaStorage is an interface to access media storage service
func GetMediaStorage ¶
func GetMediaStorage() (InterfaceMediaStorage, error)
GetMediaStorage returns currently used media storage service implementation