storage

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: AGPL-3.0 Imports: 24 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 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

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 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 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 RequiresClientDecryption

func RequiresClientDecryption(file models.File) bool

RequiresClientDecryption checks if the file needs to be decrypted by the client (if remote storage or end-to-end encryption)

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
cloudstorage
aws

Jump to

Keyboard shortcuts

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