Documentation ¶
Index ¶
- Variables
- type Config
- type Config_DiskStorage
- type Config_S3Storage
- type File
- type FileStorage
- func (fs FileStorage) AddTagsToFiles(filesIDs, tagsIDs []int)
- func (fs FileStorage) Archive(ids []int) (body io.Reader, err error)
- func (fs FileStorage) ChangeDescription(id int, newDescription string) (File, error)
- func (fs FileStorage) ChangeTags(id int, tags []int) (File, error)
- func (fs FileStorage) CheckFile(id int) bool
- func (fs FileStorage) CopyFile(w io.Writer, fileID int, resizedImage bool) error
- func (fs FileStorage) Delete(id int) error
- func (fs FileStorage) DeleteForce(id int) error
- func (fs FileStorage) Get(cnf GetFilesConfig) ([]File, error)
- func (fs FileStorage) GetFile(id int) (File, error)
- func (fs FileStorage) GetFiles(ids ...int) []File
- func (fs FileStorage) GetRecent(number int) []File
- func (fs FileStorage) Recover(id int)
- func (fs FileStorage) RemoveTagFromAllFiles(tagID int)
- func (fs FileStorage) RemoveTagsFromFiles(filesIDs, tagsIDs []int)
- func (fs FileStorage) Rename(id int, newName string) (File, error)
- func (fs FileStorage) Shutdown() error
- func (fs FileStorage) StartBackgroundJobs()
- func (fs FileStorage) Upload(f *multipart.FileHeader, tags []int) (err error)
- type FilesSortMode
- type FilterFilesFunction
- type GetFilesConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrFileIsNotExist = errors.New("the file doesn't exist") ErrAlreadyExist = errors.New("file already exists") ErrFileDeletedAgain = errors.New("file can't be deleted again") ErrOffsetOutOfBounds = errors.New("offset is out of bounds") ErrEmptyNewName = errors.New("new name can't be empty") )
Errors
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.7.0
type Config struct { Debug bool VarFolder string Encrypt bool PassPhrase [32]byte // A file is deleted from the storage and from a disk after this time since user add the file into the Trash TimeBeforeDeleting time.Duration MetadataStorageType string FilesJSONFile string FileStorageType string DiskStorage Config_DiskStorage S3Storage Config_S3Storage }
type Config_DiskStorage ¶ added in v0.10.0
type Config_S3Storage ¶ added in v0.10.0
type File ¶ added in v0.7.0
type File struct { ID int `json:"id"` Filename string `json:"filename"` Type extensions.Ext `json:"type"` Tags []int `json:"tags"` Description string `json:"description,omitempty"` Size int64 `json:"size"` AddTime time.Time `json:"addTime"` Deleted bool `json:"deleted"` TimeToDelete int64 `json:"timeToDelete,omitempty"` }
File contains the information about a file
type FileStorage ¶ added in v0.4.0
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage exposes methods for interactions with files
func NewFileStorage ¶ added in v0.4.0
func NewFileStorage(cnf Config, lg *clog.Logger) (*FileStorage, error)
NewFileStorage creates new FileStorage
func (FileStorage) AddTagsToFiles ¶ added in v0.5.0
func (fs FileStorage) AddTagsToFiles(filesIDs, tagsIDs []int)
AddTagsToFiles adds a tag to files
func (FileStorage) Archive ¶ added in v0.4.0
func (fs FileStorage) Archive(ids []int) (body io.Reader, err error)
Archive archives passed files and returns io.Reader with archive
func (FileStorage) ChangeDescription ¶ added in v0.4.0
func (fs FileStorage) ChangeDescription(id int, newDescription string) (File, error)
ChangeDescription changes the description
func (FileStorage) ChangeTags ¶ added in v0.4.0
func (fs FileStorage) ChangeTags(id int, tags []int) (File, error)
ChangeTags changes the tags
func (FileStorage) CheckFile ¶ added in v0.9.0
func (fs FileStorage) CheckFile(id int) bool
CheckFile checks if file with passed id exists
func (FileStorage) CopyFile ¶ added in v0.10.0
CopyFile copies files from disk or another storage to a passed io.Writer
func (FileStorage) Delete ¶ added in v0.4.0
func (fs FileStorage) Delete(id int) error
Delete "moves" a file into Trash
func (FileStorage) DeleteForce ¶ added in v0.4.0
func (fs FileStorage) DeleteForce(id int) error
DeleteForce deletes file from storage and from disk
func (FileStorage) Get ¶ added in v0.4.0
func (fs FileStorage) Get(cnf GetFilesConfig) ([]File, error)
Get returns all "good" sorted files
If cnf.Expr isn't valid, Get returns ErrBadExpessionSyntax
func (FileStorage) GetFile ¶ added in v0.4.0
func (fs FileStorage) GetFile(id int) (File, error)
GetFile returns a file with passed id
func (FileStorage) GetFiles ¶ added in v0.9.0
func (fs FileStorage) GetFiles(ids ...int) []File
GetFiles returns files with passed ids
func (FileStorage) GetRecent ¶ added in v0.4.0
func (fs FileStorage) GetRecent(number int) []File
GetRecent returns the last uploaded files
func (FileStorage) Recover ¶ added in v0.4.0
func (fs FileStorage) Recover(id int)
Recover "removes" file from Trash
func (FileStorage) RemoveTagFromAllFiles ¶ added in v0.10.0
func (fs FileStorage) RemoveTagFromAllFiles(tagID int)
RemoveTagFromAllFiles deletes a tag from all files
func (FileStorage) RemoveTagsFromFiles ¶ added in v0.5.0
func (fs FileStorage) RemoveTagsFromFiles(filesIDs, tagsIDs []int)
RemoveTagsFromFiles removes tags from files
func (FileStorage) Rename ¶ added in v0.4.0
func (fs FileStorage) Rename(id int, newName string) (File, error)
Rename renames a file
func (FileStorage) Shutdown ¶ added in v0.4.0
func (fs FileStorage) Shutdown() error
Shutdown gracefully shutdown FileStorage
func (FileStorage) StartBackgroundJobs ¶ added in v0.10.0
func (fs FileStorage) StartBackgroundJobs()
StartBackgroundJobs starts all background services
func (FileStorage) Upload ¶ added in v0.4.0
func (fs FileStorage) Upload(f *multipart.FileHeader, tags []int) (err error)
Upload uploads a new file
type FilesSortMode ¶ added in v0.7.0
type FilesSortMode int
const ( SortByNameAsc FilesSortMode = iota SortByNameDesc SortByTimeAsc SortByTimeDesc SortBySizeAsc SortBySizeDecs )
type FilterFilesFunction ¶ added in v0.9.0
type GetFilesConfig ¶ added in v0.9.0
type GetFilesConfig struct { Expr string SortMode FilesSortMode Search string IsRegexp bool Offset int Count int // count must be greater than 0, else all files will be returned ([offset:]) Filter FilterFilesFunction // can be nil }
Directories ¶
Path | Synopsis |
---|---|
Package bs (Binary Storage) provides different ways to keep files
|
Package bs (Binary Storage) provides different ways to keep files |