Documentation ¶
Index ¶
- Constants
- Variables
- func CleanUp(periodic bool)
- func DeleteAllEncrypted()
- 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 GetFile(id string) (models.File, bool)
- func GetFileByHotlink(id string) (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 RequiresClientDecryption(file models.File) bool
- 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 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 DeleteAllEncrypted ¶
func DeleteAllEncrypted()
DeleteAllEncrypted marks all encrypted files for deletion on next cleanup
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 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 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.
func RequiresClientDecryption ¶
RequiresClientDecryption checks if the file needs to be decrypted by the client (if remote storage or end-to-end encryption)
Types ¶
This section is empty.