Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem represents a storage for the thumbnails using the local file system.
func NewFileSystemStorage ¶
func NewFileSystemStorage(cfg config.FileSystemStorage, logger log.Logger) FileSystem
NewFileSystemStorage creates a new instance of FileSystem
func (FileSystem) BuildKey ¶
func (s FileSystem) BuildKey(r Request) string
BuildKey generate the unique key for a thumbnail. The key is structure as follows:
<first two letters of checksum>/<next two letters of checksum>/<rest of checksum>/<width>x<height>.<filetype>
e.g. 97/9f/4c8db98f7b82e768ef478d3c8612/500x300.png
The key also represents the path to the thumbnail in the filesystem under the configured root directory.
func (FileSystem) Get ¶
func (s FileSystem) Get(key string) ([]byte, error)
Get returns the file content for the given key
func (FileSystem) Put ¶
func (s FileSystem) Put(key string, img []byte) error
Put stores image data in the file system for the given key
func (FileSystem) Stat ¶
func (s FileSystem) Stat(key string) bool
Stat returns if a file for the given key exists on the filesystem
type Request ¶
type Request struct {
// The checksum of the source file
// Will be used to determine if a thumbnail exists
Checksum string
// Types provided by the encoder.
// Contains the mimetypes of the thumbnail.
// In case of jpg/jpeg it will contain both.
Types []string
// The resolution of the thumbnail
Resolution image.Rectangle
// Characteristic defines the different image characteristics,
// for example, if it's scaled up to fit in the bounding box or not,
// is it a chroma version of the image, and so on...
// the main propose for this is to be able to differentiate between images which have
// the same resolution but different characteristics.
Characteristic string
}
Request combines different attributes needed for storage operations.