Documentation ¶
Index ¶
- Constants
- Variables
- func AddHotlink(file *models.File)
- func CleanUp(periodic bool)
- func DeleteFile(keyId string, deleteSource bool) bool
- func DuplicateFile(file models.File, parametersToChange int, newFileName string, ...) (models.File, error)
- func FileExists(file models.File, dataDir string) bool
- func FormatTimestamp(timestamp int64) string
- func GetFile(id string) (models.File, bool)
- func GetFileByHotlink(id string) (models.File, bool)
- func IsAbleHotlink(file models.File) bool
- func IsExpiredFile(file models.File, timeNow int64) bool
- func NewFile(fileContent io.Reader, fileHeader *multipart.FileHeader, ...) (models.File, error)
- func NewFileFromChunk(chunkId string, fileHeader chunking.FileHeader, ...) (models.File, error)
- func ServeFile(file models.File, w http.ResponseWriter, r *http.Request, forceDownload bool)
Constants ¶
const ( // ParamExpiry is a bit to indicate that the time remaining shall be changed after a duplication ParamExpiry int = 1 << iota // ParamDownloads is a bit to indicate that the downloads remaining shall be changed after a duplication ParamDownloads // ParamPassword is a bit to indicate that the password shall be changed after a duplication ParamPassword // ParamName is a bit to indicate that the filename shall be changed after a duplication ParamName )
Variables ¶
var ErrorFileTooLarge = errors.New("upload limit exceeded")
ErrorFileTooLarge is an error that is called when a file larger than the set maximum is uploaded
Functions ¶
func AddHotlink ¶ added in v1.8.1
AddHotlink will first check if the file may use a hotlink (e.g. not encrypted or password-protected). If file is an image, it will generate a new hotlink in the database and add it to the parameter file Otherwise no changes will be made
func CleanUp ¶
func CleanUp(periodic bool)
CleanUp removes expired files from the config and from the filesystem if they are not referenced by other files anymore Will be called periodically or after a file has been manually deleted in the admin view. If parameter periodic is true, this function is recursive and calls itself every hour.
func DeleteFile ¶
DeleteFile is called when an admin requests deletion of a file Returns true if file was deleted or false if ID did not exist
func DuplicateFile ¶ added in v1.6.0
func DuplicateFile(file models.File, parametersToChange int, newFileName string, fileParameters models.UploadRequest) (models.File, error)
DuplicateFile creates a copy of an existing file with new parameters
func FileExists ¶
FileExists checks if the file exists locally or in S3
func FormatTimestamp ¶ added in v1.8.0
FormatTimestamp converts a timestamp to a string in the format YYYY-MM-DD HH:MM
func GetFile ¶
GetFile gets the file by id. Returns (empty File, false) if invalid / expired file or (file, true) if valid file
func GetFileByHotlink ¶
GetFileByHotlink gets the file by hotlink id. Returns (empty File, false) if invalid / expired file or (file, true) if valid file
func IsAbleHotlink ¶ added in v1.8.1
IsAbleHotlink returns true, if the file may use hotlinks (e.g. an image file that is not encrypted or password-protected).
func IsExpiredFile ¶
IsExpiredFile returns true if the file is expired, either due to download count or if the provided timestamp is after the expiry timestamp
func NewFile ¶
func NewFile(fileContent io.Reader, fileHeader *multipart.FileHeader, uploadRequest models.UploadRequest) (models.File, error)
NewFile creates a new file in the system. Called after an upload from the API has been completed. If a file with the same sha1 hash already exists, it is deduplicated. This function gathers information about the file, creates an ID and saves it into the global configuration. It is now only used by the API, the web UI uses NewFileFromChunk
func NewFileFromChunk ¶ added in v1.6.0
func NewFileFromChunk(chunkId string, fileHeader chunking.FileHeader, uploadRequest models.UploadRequest) (models.File, error)
NewFileFromChunk creates a new file in the system after a chunk upload has fully completed. If a file with the same sha1 hash already exists, it is deduplicated. This function gathers information about the file, creates an ID and saves it into the global configuration.
Types ¶
This section is empty.