media

package
v1.4.5-alpha1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: MPL-2.0 Imports: 1 Imported by: 7

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

View Source
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

Directories

Path Synopsis
Package fsmedia is a default implementation of InterfaceMediaStorage declared in "github.com/ottemo/commerce/media" package.
Package fsmedia is a default implementation of InterfaceMediaStorage declared in "github.com/ottemo/commerce/media" package.

Jump to

Keyboard shortcuts

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