common

package
v0.0.0-...-8497656 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2016 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ImageFormatRegex = "(?i)(jpeg|png|gif|tiff|bmp)"

Variables

This section is empty.

Functions

func IsImage

func IsImage(ext string) bool

func UploadFileHandler

func UploadFileHandler(fileRepository *FileRepository) echo.HandlerFunc

UploadFileHandler handles files upload

Types

type File

type File struct {
	UUID             string
	OriginalFilename string
	OriginalFileURL  string
	MimeType         string
	DateTimeUploaded string
	DateTimeStored   string
	DateTimeDeleted  string
	IsImage          bool
	IsReady          bool
	Size             int
	URL              string
	ImageInfo        *ImageInfo
	// contains filtered or unexported fields
}

File representation

func MakeNewFile

func MakeNewFile(filename string) *File

MakeNewFile make new File

func (*File) Ext

func (f *File) Ext() string

Ext return file ext

type FileBackend

type FileBackend interface {
	//Write tries to write the file to the backend
	Write(io.ReadCloser, *File) error
	//Read tries to get a file reader instance
	Read(*File) (io.ReadCloser, error)
	//Remove tries to remove the file from the backend
	Remove(*File) error
	//URL tries to get an url to the file
	URL(*File) (string, error)
}

FileBackend is a common interface for files storage

type FileRepository

type FileRepository struct {
	// contains filtered or unexported fields
}

FileRepository provides api to work with files

func MakeNewFileRepository

func MakeNewFileRepository(storage FileBackend, metadata MetadataBackend) *FileRepository

MakeNewFileRepository returns the new instance of FileRepository

func (*FileRepository) Upload

func (f *FileRepository) Upload(source io.ReadCloser, filename string) (*File, error)

Upload tries to upload the file and saves it to the backend

type ImageInfo

type ImageInfo struct {
	Width            int
	Height           int
	DateTimeOriginal string
	Format           string
	GeoLocation      string
}

ImageInfo information

type MetadataBackend

type MetadataBackend interface {
	//Insert tries to insert a new file metadata
	Insert(*File) error
	//Update tries to update a file metadata
	Update(*File) error
	//Delete tries to delete a file metadata
	Delete(*File) error
	//Query tries to get list of files metadata
	Query(interface{}) ([]*File, error)
}

MetadataBackend is a common interface for files metadata storage

Jump to

Keyboard shortcuts

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