media

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrongFormat       = errors.New("Wrong Format ")
	ErrFileAlreadyExists = errors.New("File already exist")
)
View Source
var (
	ErrWrongBase64Format = errors.New("Wrong Image Data Format ")
)

Functions

func SaveBts

func SaveBts(bts []byte, fileName string) error

SaveMp4

func SavePng

func SavePng(img image.Image, fileName string) error

SavePng Saves the image as a png, returns an error

Types

type ImageData

type ImageData struct {
	Title   string
	Picture string
}

ImageData represent the uploaded data

func (*ImageData) GetPicture

func (im *ImageData) GetPicture() (image.Image, error)

GetPicture returns the Image and the error

type Media

type Media struct {
	ImageDir string
	VideoDir string
}

Image represents the objects from where files are uploaded and gathered

func New

func New(imagePath, videoPath string) (im *Media, err error)

New creates a new Media for uploading and serving images from a specific folder

func (*Media) Get

func (im *Media) Get(filename string) string

TODO implement

func (*Media) Image

func (im *Media) Image(r *http.Request) (fileName string, err error)

Image handles the upload of the request

func (*Media) ListImages

func (im *Media) ListImages() []string

ListImages returns a list of uploaded images

func (*Media) ListVideos

func (im *Media) ListVideos() []VideoInfo

ListVideos returns a list of videos

func (*Media) ListVideosByTime

func (im *Media) ListVideosByTime(start, stop int) []VideoInfo

ListVideosByTime

func (*Media) Video

func (im *Media) Video(r *http.Request) (fileName string, err error)

UploadVideo

type VideoInfo

type VideoInfo struct {
	Name  string `json:"name"`
	Start int    `json:"start"`
	Stop  int    `json:"stop"`
	// duration in seconds
	Duration int `json:"duration"`
}

func ConvertToVideoInfo

func ConvertToVideoInfo(raw string) (*VideoInfo, error)

1568723655748-1568723660188.webm

Jump to

Keyboard shortcuts

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