Documentation
¶
Index ¶
Constants ¶
View Source
const ( ContentTypeFormData ContentType = "multipart/form-data" // Supported content types for images ContentTypeJPEG ContentType = "image/jpeg" ContentTypePNG ContentType = "image/png" ContentTypeGIF ContentType = "image/gif" ContentTypeBIMP ContentType = "image/bimg" ContentTypeWEBP ContentType = "image/webp" // Storage type options StorageTypeLocalDisk StorageType = "localdisk" StorageTypeS3 StorageType = "s3" // Database options DBTypePostgres DBType = "postgres" DBTypeSQLite DBType = "sqlite" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentType ¶
type ContentType string
ContentType represents HTTP MIME types sent in Content-type header
type ImageProcessor ¶
type ImageProcessor interface { Resize(buff []byte, width, height int) ([]byte, error) Rotage(buff []byte, degree int) ([]byte, error) Grayscale(buff []byte) ([]byte, error) }
ImageProcessor interface provides image processing methods
type Media ¶
type Media struct { ID string `json:"id"` // Numeric id (db primary key) URL string `json:"url"` // url to access the file over internet Origin string `json:"origin"` // Origin domain of the file ContentType ContentType `json:"contentType"` // SizeBytes int64 `json:"sizeBytes"` // Size of the file in bytes Timestamp int64 `json:"tmestamp"` // Media creation timestamp Base64Hash string `json:"base64Hash"` // Base64 hash of the file used as a unique string identifier }
Media is a representation of mediateq file.
func (Media) GetFilePath ¶
GetFilePath return the path to a media file 2 subdirectories are created for more manageable browsing and use the remainder as the file name. For example, if Base64Hash is 'qwerty' and content type is 'image/png' the path will be 'q/w/erty'.
type Storage ¶
type Storage interface { // Write method write file buffer to storage and // return the relative path and an error if the write operating fail Write(ctx context.Context, buff []byte, filePath string) error // Read method read a file from storage and return // the relative path and an error if the read operation fail Read(ctx context.Context, filePath string) ([]byte, error) // Remove method should remove a file from // the storage given the path to the target file Remove(ctx context.Context, path string) error }
Storage is an abstration of place where files are stored
type StorageType ¶
type StorageType string
StorageType represents type of storage where media are stored
type Thumbnail ¶
type Thumbnail struct { Media ThumbnailSize }
type ThumbnailSize ¶
Click to show internal directories.
Click to hide internal directories.