media

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Asc  = "asc"
	Desc = "desc"
)

Variables

This section is empty.

Functions

func IsContentTypeSupported

func IsContentTypeSupported(c ContentType) bool

Types

type Body

type Body = *[]byte

type ContentLength

type ContentLength = int64

type ContentType

type ContentType = string
const (
	ImageJpg  ContentType = "image/jpg"
	ImageJpeg ContentType = "image/jpeg"
	ImagePng  ContentType = "image/png"
	ImageWebp ContentType = "image/webp"
	VideoMp4  ContentType = "video/mp4"
	VideoMkv  ContentType = "video/x-matroska"
)

type DerivedMedia

type DerivedMedia struct {
	Path
	Body          Body          `json:"-"`
	ContentType   ContentType   `json:"content_type,omitempty"`
	ContentLength ContentLength `json:"content_length,omitempty"`
	CreatedAt     time.Time     `json:"created_at,omitempty"`
	UpdatedAt     time.Time     `json:"updated_at,omitempty"`
}

type DownloadResponse

type DownloadResponse struct {
	Body          io.ReadCloser
	ContentType   ContentType
	ContentLength int64
}

type FileInfo

type FileInfo struct {
	Path
	ContentType   ContentType   `json:"content_type,omitempty"`
	ContentLength ContentLength `json:"content_length,omitempty"`
}

type FileStorer

type FileStorer interface {
	Upload(in UploadInput) error
	Download(p Path) (*DownloadResponse, error)
	DownloadArchive(p []Path) (Body, error)
	ReadOne(p Path) (*FileInfo, error)
	ReadMany(p Path) ([]FileInfo, error)
	Move(src, dst Path) error
	Copy(src, dst Path) error
	Delete(p Path) error
	SpaceUsage() (float64, error)
}

type Media

type Media struct {
	Path
	Body             Body           `json:"-"`
	ContentType      ContentType    `json:"content_type,omitempty"`
	ContentLength    ContentLength  `json:"content_length,omitempty"`
	EmbeddedMetadata Metadata       `json:"embedded_metadata,omitempty"`
	Tags             []Tag          `json:"tags,omitempty"`
	DerivedMedias    []DerivedMedia `json:"derived_medias,omitempty"`
	CreatedAt        time.Time      `json:"created_at,omitempty"`
	UpdatedAt        time.Time      `json:"updated_at,omitempty"`
}

type Metadata

type Metadata map[string]string

type Path

type Path struct {
	Path string `json:"path"`
}

func NewPath

func NewPath(path string) Path

func (*Path) AppendSuffix

func (p *Path) AppendSuffix(suffix string) Path

func (*Path) BasePath

func (p *Path) BasePath() Path

func (*Path) Basename

func (p *Path) Basename() string

func (*Path) Dir

func (p *Path) Dir() string

func (*Path) Extension

func (p *Path) Extension() string

func (*Path) Filename

func (p *Path) Filename() string

func (*Path) SetDir

func (p *Path) SetDir(dir string) Path

func (*Path) SetExtension

func (p *Path) SetExtension(ext string) Path

func (*Path) ToString

func (p *Path) ToString() string

func (*Path) Uuid

func (p *Path) Uuid() string

type PathFactory

type PathFactory struct {
}

func (*PathFactory) BuildDerivedMedisPath

func (f *PathFactory) BuildDerivedMedisPath(m Media) Path

type ReadManyInput

type ReadManyInput struct {
	Path   Path
	Offset int
	Limit  int
	SortBy string
	Asc    bool
}

type SortBy

type SortBy = map[string]string

type Storer

type Storer interface {
	ReadOne(path Path) (*Media, error)
	ReadMany(in ReadManyInput) ([]Media, error)
	Save(media *Media) error
	Delete(path Path) error
}

type Tag

type Tag struct {
	Value           string  `json:"value"`
	ConfidenceScore float32 `json:"confidence_score"`
	Provider        string  `json:"provider"`
}

type UploadInput

type UploadInput struct {
	Path          Path
	Body          io.Reader
	ContentType   ContentType
	ContentLength ContentLength
}

Jump to

Keyboard shortcuts

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