FlysystemAssetStore
class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable
Asset store based on flysystem Filesystem as a backend
Traits
Constants
GRANTS_SESSION |
Session key to use for user grants |
Config options
legacy_filenames | bool | Enable to use legacy filename behaviour (omits hash and uses the natural filename). | |
keep_empty_dirs | bool | Flag if empty folders are allowed. | |
denied_response_code | int | Set HTTP error code for requests to secure denied assets. | |
missing_response_code | int | Set HTTP error code to use for missing secure assets | |
redirect_response_code | int | Define the HTTP Response code for request that should be temporarily redirected to a different URL. Defaults to 302. | |
permanent_redirect_response_code | int | Define the HTTP Response code for request that should be permanently redirected to a different URL. Defaults to 301. | |
file_response_headers | array | Custom headers to add to all custom file responses |
Methods
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
Gets the uninherited value for the given config option
Assign new flysystem backend
Get the currently assigned flysystem backend
Assign filesystem to use for non-public files
Get filesystem to use for non-public files
Return list of feature capabilities of this backend as an array.
Determine visibility of the given file
Get a stream for this file
Get contents of a given file
Get the url for the file
Assign a local file to the backend.
Assign a set of data to the backend
Assign a stream to the backend
Delete a file (and all variants) identified by the given filename and hash
Rename a file (and all variants) to a new filename
Copy a file (and all variants) to a new filename
Publicly expose the file (and all variants) identified by the given filename and hash
Similar to publish, only any existing files that would be overriden by publishing will be moved back to the protected store.
Protect a file (and all variants) from public access, identified by the given filename and hash.
Ensures that access to the specified protected file is granted for the current user.
Revoke access to the given file for the current user.
Check if the current user can view the given file.
Get metadata for this file, if available
Get mime type of this file
Determine if a file exists with the given tuple
Ensure each adapter re-generates its own server configuration files
Generate a custom HTTP response for a request to a given asset, identified by a path.
No description
No description
Details
in Configurable at line 20
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
....).
in Configurable at line 32
mixed
stat(string $name)
deprecated
deprecated 5.0 Use ->config()->get() instead
Get inherited config value
in Configurable at line 44
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
in Configurable at line 57
$this
set_stat(string $name, mixed $value)
deprecated
deprecated 5.0 Use ->config()->set() instead
Update the config value for a given property
at line 146
$this
setPublicFilesystem(Filesystem $filesystem)
Assign new flysystem backend
at line 161
Filesystem
getPublicFilesystem()
Get the currently assigned flysystem backend
at line 176
$this
setProtectedFilesystem(Filesystem $filesystem)
Assign filesystem to use for non-public files
at line 191
Filesystem
getProtectedFilesystem()
Get filesystem to use for non-public files
at line 428
array
getCapabilities()
Return list of feature capabilities of this backend as an array.
Array keys will be the options supported by $config, and the values will be the list of accepted values for each option (or true if any value is allowed).
at line 444
string
getVisibility(string $filename, string $hash)
Determine visibility of the given file
at line 454
resource
getAsStream(string $filename, string $hash, string|null $variant = null)
Get a stream for this file
at line 464
string
getAsString(string $filename, string $hash, string|null $variant = null)
Get contents of a given file
at line 474
string
getAsURL(string $filename, string $hash, string|null $variant = null, bool $grant = true)
Get the url for the file
at line 503
array
setFromLocalFile(string $path, string $filename = null, string $hash = null, string $variant = null, array $config = array())
Assign a local file to the backend.
at line 529
array
setFromString(string $data, string $filename, string $hash = null, string $variant = null, array $config = array())
Assign a set of data to the backend
at line 543
array
setFromStream(resource $stream, string $filename, string $hash = null, string $variant = null, array $config = array())
Assign a stream to the backend
at line 593
bool
delete(string $filename, string $hash)
Delete a file (and all variants) identified by the given filename and hash
at line 608
string
rename(string $filename, string $hash, string $newName)
Rename a file (and all variants) to a new filename
at line 657
string|null
copy(string $filename, string $hash, string $newName)
Copy a file (and all variants) to a new filename
at line 782
publish(string $filename, string $hash)
Publicly expose the file (and all variants) identified by the given filename and hash
at line 808
swapPublish($filename, $hash)
Similar to publish, only any existing files that would be overriden by publishing will be moved back to the protected store.
at line 879
protect(string $filename, string $hash)
Protect a file (and all variants) from public access, identified by the given filename and hash.
A protected file can be granted access to users on a per-session or per-user basis as response to any future invocations of {see grant()} or {see getAsURL()} with $grant = true
at line 966
grant(string $filename, string $hash)
Ensures that access to the specified protected file is granted for the current user.
If this file is currently in protected mode, the asset store will ensure the returned asset for the duration of the current session / user. This will have no effect if the file is in published mode. This will not grant access to users other than the owner of the current session. Does not require a member to be logged in.
at line 977
revoke(string $filename, string $hash)
Revoke access to the given file for the current user.
Note: This will have no effect if the given file is public
at line 994
bool
canView(string $filename, string $hash)
Check if the current user can view the given file.
at line 1209
array|null
getMetadata(string $filename, string $hash, string|null $variant = null)
Get metadata for this file, if available
at line 1220
string
getMimeType(string $filename, string $hash, string|null $variant = null)
Get mime type of this file
at line 1231
bool
exists(string $filename, string $hash, string|null $variant = null)
Determine if a file exists with the given tuple
at line 1427
static
flush()
Ensure each adapter re-generates its own server configuration files
at line 1450
HTTPResponse
getResponseFor(string $asset)
Generate a custom HTTP response for a request to a given asset, identified by a path.