Documentation ¶
Index ¶
Constants ¶
View Source
const ImageFormatRegex = "(?i)(jpeg|png|gif|tiff|bmp)"
Variables ¶
This section is empty.
Functions ¶
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
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
Click to show internal directories.
Click to hide internal directories.