Documentation ¶
Overview ¶
Package file contains operations with files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶
CopyFile copies file from src to dest.
func DirHasReadableFiles ¶
DirHasReadableFiles returns false when input directories don't have any file that can be open for read
func IsImage ¶
IsImage returns true if mediaType is valid mime type and mime type represents image. If mediaType is invalid mime type, mime type is defined by filename.
Types ¶
type EtagEncoder ¶
EtagEncoder is used to generate etag based on file content.
func NewEtagEncoder ¶
func NewEtagEncoder() EtagEncoder
type Storage ¶
type Storage interface { // Move moves file from src to local storage. Move(id, src string) (hashPath string, err error) // Copy copies file from src to local storage. Copy(id, src string) (hashPath string, err error) CopyReader(id string, src io.Reader) (hashPath string, err error) // GetFilepath returns absolute file path. GetFilepath(id, hashPath string) string // Delete removes file from local storage. Delete(id, hashPath string) error // DeleteByName removes file or empty dir. It returns (false, nil) if dir is not empty. DeleteByName(name string) (bool, error) // GetEtag returns etag of file content. GetEtag(id, hashPath string) (string, error) }
Storage is used to implement file modification operations.
func NewStorage ¶
func NewStorage(filesRoot string, etagEncoder EtagEncoder) Storage
Click to show internal directories.
Click to hide internal directories.