storage

package
v1.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2024 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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(file *models.File)

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

func DeleteFile(keyId string, deleteSource bool) bool

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

func FileExists(file models.File, dataDir string) bool

FileExists checks if the file exists locally or in S3

func FormatTimestamp added in v1.8.0

func FormatTimestamp(timestamp int64) string

FormatTimestamp converts a timestamp to a string in the format YYYY-MM-DD HH:MM

func GetFile

func GetFile(id string) (models.File, bool)

GetFile gets the file by id. Returns (empty File, false) if invalid / expired file or (file, true) if valid file

func GetFileByHotlink(id string) (models.File, bool)

GetFileByHotlink gets the file by hotlink id. Returns (empty File, false) if invalid / expired file or (file, true) if valid file

func IsAbleHotlink(file models.File) bool

IsAbleHotlink returns true, if the file may use hotlinks (e.g. an image file that is not encrypted or password-protected).

func IsExpiredFile

func IsExpiredFile(file models.File, timeNow int64) bool

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 ServeFile

func ServeFile(file models.File, w http.ResponseWriter, r *http.Request, forceDownload bool)

ServeFile subtracts a download allowance and serves the file to the browser

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL