FilesApp
class FilesApp extends InstalledApp
App that provides user-facing filesystem services.
Provides a general filesystem API for managing files and folders, as well as admin-level functions like managing filesystems and config.
Supports features like random-level byte access, multiple (user or admin-added) filesystems with various backend storage drivers, social features including likes and comments, sharing of content via links or to users or groups, configurable rules per-account or per-filesystem, and granular statistics gathering and limiting for accounts/groups/filesystems.
Properties
| protected | $API | Reference to the main API, for convenience |
from BaseApp |
| static private | $metadata | from BaseApp | |
| protected | $config | from InstalledApp | |
| protected | $database | from InstalledApp |
Methods
Returns an array of strings showing the CLI usage of the app
No description
Return this app's BaseAppLog class name, if used (or null)
Loads a metadata for the given app with the given key
Tells the app to commit any changes made outside the database
Tells the app to rollback any changes made outside the database
Return the BaseConfig class for this app
Iterates over the list of upgrade scripts, running them sequentially until the DB is up to date with the code
Returns an ItemAccess authenticating the given file ID (or null to get from input), throws exceptions on failure
Returns an ItemAccess authenticating the given folder ID (or null to get from input), throws exceptions on failure
Returns an ItemAccess authenticating the given folder ID (or null to get from input), returns null on failure
Throws an unknown file/folder exception if given, else item exception
Returns an ItemAccess authenticating the given item class/ID, throws exceptions on failure
Returns an ItemAccess authenticating the given item class/ID, returns null on failure
Returns an ItemAccess authenticating the given already-loaded object
Uploads a new file to the given folder. Bandwidth is counted.
Downloads a file or part of a file
Writes new data to an existing file - data is posted as a file
Truncates (resizes a file)
Returns file metadata
Reads an item by a path (rather than by ID) - can specify a root folder or filesystem
Edits folder metadata
Creates a folder in the given parent
Deletes a file
Deletes a folder
Deletes an item.
Renames (or copies) a file
Renames (or copies) a folder
Renames or copies an item
Moves (or copies) a folder
Likes or dislikes a folder
Adds a comment to a file
Adds a comment to a folder
Adds a comment to an item
Deletes a comment
Returns comments on a file
Returns comments on a folder
Returns likes on a file
Returns likes on a folder
Creates shares for a folder
Deletes an existing share
Returns a list of all items where the user owns the item but not the parent
Returns filesystem metadata (default if none specified)
Returns a list of all filesystems available
Creates a new filesystem
Removes a filesystem (and potentially its content)
Common function for loading and authenticating the limited object and limit class referred to by input
Loads the timed limit object or objects for the given objects
Returns all stored time stats for an object
Returns timed stats for the given object or objects at the given time
Configures total limits for the given object
Configures timed limits for the given object
Deletes all total limits for the given object
Deletes all timed limits for the given object
Details
in
InstalledApp at line 126
__construct(Main $API)
All apps are constructed when Andromeda runs
at line 188
mixed
Run(Input $input)
Checks if the client is running/needs to run install/upgrade {@inheritDoc}
at line 112
static array
getUsage()
Returns an array of strings showing the CLI usage of the app
at line 104
static string
getName()
No description
at line 106
static protected string|null
getLogClass()
Return this app's BaseAppLog class name, if used (or null)
in
BaseApp at line 59
static protected
getMetadata(string $app, string $key)
Loads a metadata for the given app with the given key
Loads the app's JSON metadata file but not its code
in
BaseApp at line 77
static array
getAppRequires(string $app)
No description
in
BaseApp at line 83
static string
getAppApiVersion(string $app)
No description
in
BaseApp at line 89
static string
getVersion()
No description
at line 180
commit()
Tells the app to commit any changes made outside the database
at line 181
rollback()
Tells the app to rollback any changes made outside the database
in
InstalledApp at line 107
static protected string
getInstallFlags()
No description
in
InstalledApp at line 108
static protected string
getUpgradeFlags()
No description
in
InstalledApp at line 110
static protected array
getInstallUsage()
No description
at line 108
static protected string
getConfigClass()
Return the BaseConfig class for this app
in
InstalledApp at line 144
protected bool
allowInstall()
Returns true if the user is allowed to install/upgrade
in
InstalledApp at line 151
static protected string
getTemplateFolder()
Returns the path of the app's code folder
in
InstalledApp at line 157
static protected array
getUpgradeScripts()
No description
in
InstalledApp at line 194
protected
Install(Input $input)
Installs the app by importing its SQL file and creating config
in
InstalledApp at line 207
protected
Upgrade(Input $input)
Iterates over the list of upgrade scripts, running them sequentially until the DB is up to date with the code
at line 110
protected Config
GetConfig()
No description
at line 268
private ItemAccess
AuthenticateFileAccess(Input $input, Authenticator|null $auth, AccessLog|null $accesslog, string|null $id = null)
Returns an ItemAccess authenticating the given file ID (or null to get from input), throws exceptions on failure
at line 275
private ItemAccess
AuthenticateFolderAccess(Input $input, Authenticator|null $auth, AccessLog|null $accesslog, string|null $id = null, bool $isParent = false)
Returns an ItemAccess authenticating the given folder ID (or null to get from input), throws exceptions on failure
at line 282
private ItemAccess|null
TryAuthenticateFolderAccess(Input $input, Authenticator|null $auth, AccessLog|null $accesslog, string|null $id = null, bool $isParent = false)
Returns an ItemAccess authenticating the given folder ID (or null to get from input), returns null on failure
at line 289
static private void
UnknownItemException(string|null $class = null)
Throws an unknown file/folder exception if given, else item exception
at line 300
private ItemAccess
AuthenticateItemAccess(Input $input, Authenticator|null $auth, AccessLog|null $accesslog, string $class, string|null $id, bool $isParent = false)
Returns an ItemAccess authenticating the given item class/ID, throws exceptions on failure
at line 319
private ItemAccess|null
TryAuthenticateItemAccess(Input $input, Authenticator|null $auth, AccessLog|null $accesslog, string $class, string|null $id, bool $isParent = false)
Returns an ItemAccess authenticating the given item class/ID, returns null on failure
at line 339
private ItemAccess
AuthenticateItemObjAccess(Input $input, Authenticator|null $auth, AccessLog|null $accesslog, Item $item, bool $isParent = false)
Returns an ItemAccess authenticating the given already-loaded object
at line 353
protected array
RunGetConfig(Input $input, Authenticator|null $authenticator)
Gets config for this app
at line 366
protected array
RunSetConfig(Input $input, Authenticator|null $authenticator)
Sets config for this app
at line 382
protected array
UploadFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Uploads a new file to the given folder. Bandwidth is counted.
at line 431
protected void
DownloadFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Downloads a file or part of a file
Can accept an input byte range. Also accepts the HTTP_RANGE header.
at line 517
protected array
WriteToFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Writes new data to an existing file - data is posted as a file
If no offset is given, the default is to append the file (offset = file size) DO NOT use this in a multi-action transaction as the underlying FS cannot fully rollback writes. The FS will restore the original size of the file but writes within the original size are permanent.
at line 579
protected array
TruncateFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Truncates (resizes a file)
DO NOT use this in a multi-action transaction as the underlying FS cannot fully rollback truncates. The FS will restore the original size of the file but if the file was shrunk, data will be zeroed.
at line 605
protected array
GetFileMeta(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Returns file metadata
at line 626
protected array
GetFolder(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Lists folder metadata and optionally the items in a folder (or filesystem root)
at line 683
protected array
GetItemByPath(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Reads an item by a path (rather than by ID) - can specify a root folder or filesystem
NOTE that /. and /.. have no special meaning - no traversal allowed
at line 749
protected array|null
EditFileMeta(Input $input, Authenticator|null $auth, AccessLog|null $accesslog)
Edits file metadata
at line 758
protected array|null
EditFolderMeta(Input $input, Authenticator|null $auth, AccessLog|null $accesslog)
Edits folder metadata
at line 770
private array
EditItemMeta(ItemAccess $access, Input $input)
Edits item metadata
at line 786
protected array
OwnFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Takes ownership of a file
at line 809
protected array
OwnFolder(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Takes ownership of a folder
at line 843
protected array
CreateFolder(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Creates a folder in the given parent
at line 871
protected void
DeleteFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes a file
at line 880
protected void
DeleteFolder(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes a folder
at line 896
private void
DeleteItem(string $class, string $key, Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes an item.
DO NOT use this in a multi-action transaction as the underlying FS cannot rollback deletes. If you delete an item and then do another action that results in an error, the content will still be deleted on disk though the database objects will remain.
at line 920
protected array
RenameFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Renames (or copies) a file
at line 931
protected array
RenameFolder(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Renames (or copies) a folder
at line 943
private array
RenameItem(string $class, string $key, Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Renames or copies an item
at line 993
protected array
MoveFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Moves (or copies) a file
at line 1004
protected array
MoveFolder(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Moves (or copies) a folder
at line 1016
private array
MoveItem(string $class, string $key, Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Moves or copies an item.
at line 1060
protected array
LikeFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Likes or dislikes a file
at line 1069
protected array
LikeFolder(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Likes or dislikes a folder
at line 1083
private array|null
LikeItem(string $class, string $key, Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Likes or dislikes an item
at line 1105
protected array
TagFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Adds a tag to a file
at line 1114
protected array
TagFolder(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Adds a tag to a folder
at line 1128
private array
TagItem(string $class, string $key, Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Adds a tag to an item
at line 1156
protected void
DeleteTag(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes an item tag
at line 1180
protected array
CommentFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Adds a comment to a file
at line 1189
protected array
CommentFolder(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Adds a comment to a folder
at line 1203
private array
CommentItem(string $class, string $key, Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Adds a comment to an item
at line 1229
protected array
EditComment(Input $input, Authenticator|null $authenticator)
Edits an existing comment properties
at line 1250
protected void
DeleteComment(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes a comment
at line 1270
protected array
GetFileComments(Input $input, Authenticator|null $auth, AccessLog|null $accesslog)
Returns comments on a file
at line 1279
protected array
GetFolderComments(Input $input, Authenticator|null $auth, AccessLog|null $accesslog)
Returns comments on a folder
at line 1291
private array
GetItemComments(ItemAccess $access, Input $input)
Returns comments on an item
at line 1309
protected array
GetFileLikes(Input $input, Authenticator|null $auth, AccessLog|null $accesslog)
Returns likes on a file
at line 1318
protected array
GetFolderLikes(Input $input, Authenticator|null $auth, AccessLog|null $accesslog)
Returns likes on a folder
at line 1330
private array
GetItemLikes(ItemAccess $access, Input $input)
Returns likes on an item
at line 1348
protected array
ShareFile(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Creates shares for a file
at line 1357
protected array
ShareFolder(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Creates shares for a folder
at line 1374
private array
ShareItem(string $class, string $key, Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Creates shares for an item
at line 1464
protected array
EditShare(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Edits properties of an existing share
at line 1487
protected void
DeleteShare(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes an existing share
at line 1516
protected array
ShareInfo(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Retrieves metadata on a share object (from a link)
at line 1533
protected array
ListShares(Input $input, Authenticator|null $authenticator)
Returns a list of shares
if $mine, show all shares we created, else show all shares we're the target of
at line 1557
protected array
ListAdopted(Input $input, Authenticator|null $authenticator)
Returns a list of all items where the user owns the item but not the parent
These are items that the user uploaded into someone else's folder, but owns
at line 1578
protected array
GetFilesystem(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Returns filesystem metadata (default if none specified)
at line 1606
protected array
GetFilesystems(Input $input, Authenticator|null $authenticator)
Returns a list of all filesystems available
at line 1630
protected array
CreateFilesystem(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Creates a new filesystem
at line 1654
protected array
EditFilesystem(Input $input, Authenticator|null $authenticator)
Edits an existing filesystem
at line 1675
protected void
DeleteFilesystem(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Removes a filesystem (and potentially its content)
at line 1709
private array
GetLimitObject(Input $input, Authenticator|null $authenticator, bool $allowAuto, bool $allowMany, bool $timed)
Common function for loading and authenticating the limited object and limit class referred to by input
at line 1770
protected array|null
GetLimits(Input $input, Authenticator|null $authenticator)
Loads the total limit object or objects for the given objects
Defaults to the current account if none specified
at line 1802
protected array
GetTimedLimits(Input $input, Authenticator|null $authenticator)
Loads the timed limit object or objects for the given objects
Defaults to the current account if none specified
at line 1833
protected array|null
GetTimedStatsFor(Input $input, Authenticator|null $authenticator)
Returns all stored time stats for an object
Defaults to the current account if none specified
at line 1860
protected array|null
GetTimedStatsAt(Input $input, Authenticator|null $authenticator)
Returns timed stats for the given object or objects at the given time
Defaults to the current account if none specified
at line 1901
protected array
ConfigLimits(Input $input, Authenticator|null $authenticator)
Configures total limits for the given object
at line 1919
protected array
ConfigTimedLimits(Input $input, Authenticator|null $authenticator)
Configures timed limits for the given object
at line 1935
protected void
PurgeLimits(Input $input, Authenticator|null $authenticator)
Deletes all total limits for the given object
at line 1951
protected void
PurgeTimedLimits(Input $input, Authenticator|null $authenticator)
Deletes all timed limits for the given object