FilesBackendDirectory
extends FilesBackend
in package
Backend for the files module which stores files in a local directory
Table of Contents
Properties
- $backend_type : mixed
- This should match the key in Kohana::config("file.file_backends")
- $logging : bool|callable
Methods
- absUrl() : string
- Returns the absolute URL for a given file id, including domain.
- baseDir() : string
- Generate server files base directory path
- cleanupLocalCopy() : bool
- Remove a local copy of a file
- clearCacheResponse() : void
- Clear a cached file function response
- clearCaches() : void
- Clear all caches for a given file
- createLocalCopy() : string|null
- Create a copy of the file in a temporary directory.
- delete() : bool
- Delete a file
- deleteDir() : mixed
- Delete a directory
- exists() : bool
- Determine if a file exists
- getCacheKey() : string
- Get a repeatable and predictable rdb key for a file function response
- getCacheResponse() : mixed
- Get a cached file function response
- getConfig() : array<string|int, mixed>
- Get the config settings for the current backend
- getName() : string
- Get the name for the current backend
- getSettings() : array<string|int, mixed>
- Get the AWS config merge settings.
- getStream() : StreamInterface|null
- Get a PSR stream for a file.
- getString() : string|false
- Returns file content as a string. Basically the same as file_get_contents
- getTransformFolderPrefix() : string
- getType() : string
- Get the 'type' key for the current backend
- glob() : array<string|int, mixed>
- Returns all files which match the specified mask.
- imageSize() : array<string|int, mixed>|false
- Returns the size of an image, or false on failure.
- mkDir() : mixed
- Create an empty directory
- moveFile() : bool
- Moves a file within the backend context.
- moveUpload() : bool
- Moves an uploaded file into the repository.
- mtime() : int|false
- Get the modified time, in unix timestamp format, of the specified file
- putExisting() : bool
- Saves file content from an existing (local) file
- putStream() : bool
- Saves file content from a stream. Basically just fopen/stream_copy_to_stream/fclose
- putString() : bool
- Saves file content as a string. Basically the same as file_put_contents
- readfile() : int|false
- This is the equivalent of the php readfile function
- relUrl() : string
- Returns the relative URL for a given file.
- resizeUrl() : string
- Returns the relative URL for a dynamically resized image.
- setCacheResponse() : void
- Set a cached file function response
- setLogging() : void
- Override the logging.
- size() : int|false
- Get the size, in bytes, of the specified file
- touch() : bool
- Sets access and modification time of file
- log() : void
- Log a mesasge or exception.
- createFolderPath() : void
- Ensure that a folder path exists for target files.
Properties
$backend_type
This should match the key in Kohana::config("file.file_backends")
protected
mixed
$backend_type
= 'local'
$logging
protected
bool|callable
$logging
= !IN_PRODUCTION
Methods
absUrl()
Returns the absolute URL for a given file id, including domain.
public
absUrl(mixed $filename) : string
Parameters
- $filename : mixed
Tags
Return values
string —e.g. http://example.com/files/filename.jpg
baseDir()
Generate server files base directory path
public
baseDir() : string
Return values
stringcleanupLocalCopy()
Remove a local copy of a file
public
cleanupLocalCopy(string $temp_filename) : bool
Parameters
- $temp_filename : string
-
The filename returned by createLocalCopy
Return values
boolclearCacheResponse()
Clear a cached file function response
public
clearCacheResponse(string $function, string $filename) : void
Parameters
- $function : string
- $filename : string
clearCaches()
Clear all caches for a given file
public
clearCaches(string $filename) : void
Parameters
- $filename : string
createLocalCopy()
Create a copy of the file in a temporary directory.
public
createLocalCopy(mixed $filename) : string|null
Parameters
- $filename : mixed
-
The file to copy into a temporary location
Tags
Return values
string|null —Temp filename or NULL on error
delete()
Delete a file
public
delete(string $filename) : bool
Parameters
- $filename : string
Tags
Return values
booldeleteDir()
Delete a directory
public
deleteDir(mixed $directory) : mixed
Parameters
- $directory : mixed
Tags
exists()
Determine if a file exists
public
exists(string $filename) : bool
Parameters
- $filename : string
-
The file to check for
Tags
Return values
bool —Returns TRUE if the file exists, and FALSE if it does not
getCacheKey()
Get a repeatable and predictable rdb key for a file function response
public
getCacheKey(string $function, string $filename) : string
Parameters
- $function : string
- $filename : string
Return values
stringgetCacheResponse()
Get a cached file function response
public
getCacheResponse(string $function, string $filename) : mixed
Parameters
- $function : string
- $filename : string
Return values
mixed —Cache val or null if empty
getConfig()
Get the config settings for the current backend
public
getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>getName()
Get the name for the current backend
public
getName() : string
Return values
stringgetSettings()
Get the AWS config merge settings.
public
getSettings() : array<string|int, mixed>
Return values
array<string|int, mixed>getStream()
Get a PSR stream for a file.
public
getStream(string $filename) : StreamInterface|null
Parameters
- $filename : string
Tags
Return values
StreamInterface|nullgetString()
Returns file content as a string. Basically the same as file_get_contents
public
getString(string $filename) : string|false
Parameters
- $filename : string
Tags
Return values
string|falsegetTransformFolderPrefix()
public
getTransformFolderPrefix() : string
Tags
Return values
stringgetType()
Get the 'type' key for the current backend
public
getType() : string
Return values
stringglob()
Returns all files which match the specified mask.
public
glob(string $mask[, mixed $depth = 0 ]) : array<string|int, mixed>
Parameters
- $mask : string
-
The search mask / string
- $depth : mixed = 0
Tags
Return values
array<string|int, mixed> —An array of results from the lookup
imageSize()
Returns the size of an image, or false on failure.
public
imageSize(string $filename) : array<string|int, mixed>|false
Parameters
- $filename : string
Tags
Return values
array<string|int, mixed>|false —depending if found
mkDir()
Create an empty directory
public
mkDir(mixed $directory) : mixed
Parameters
- $directory : mixed
Tags
moveFile()
Moves a file within the backend context.
public
moveFile(string $src, string $filename) : bool
Parameters
- $src : string
-
The source filename to move
- $filename : string
Tags
Return values
bool —Returns TRUE on success, FALSE on failure.
moveUpload()
Moves an uploaded file into the repository.
public
moveUpload(string $src, string $filename) : bool
Parameters
- $src : string
-
The source file to move
- $filename : string
-
The filename to move it to
Tags
Return values
bool —Returns TRUE on success, FALSE on failure.
mtime()
Get the modified time, in unix timestamp format, of the specified file
public
mtime(string $filename) : int|false
Parameters
- $filename : string
Tags
Return values
int|false —The modified file timestamp
putExisting()
Saves file content from an existing (local) file
public
putExisting(string $filename, string $existing) : bool
Parameters
- $filename : string
- $existing : string
Tags
Return values
boolputStream()
Saves file content from a stream. Basically just fopen/stream_copy_to_stream/fclose
public
putStream(string $filename, mixed $stream) : bool
Parameters
- $filename : string
- $stream : mixed
Tags
Return values
boolputString()
Saves file content as a string. Basically the same as file_put_contents
public
putString(mixed $filename, mixed $content) : bool
Parameters
- $filename : mixed
- $content : mixed
Tags
Return values
boolreadfile()
This is the equivalent of the php readfile function
public
readfile(string $filename) : int|false
Parameters
- $filename : string
Tags
Return values
int|falserelUrl()
Returns the relative URL for a given file.
public
relUrl(mixed $filename) : string
Parameters
- $filename : mixed
Tags
Return values
string —e.g. files/filename.jpg
resizeUrl()
Returns the relative URL for a dynamically resized image.
public
resizeUrl(string $filename, string $size) : string
Size formatting is as per File::parseSizeString, e.g. c400x300
Parameters
- $filename : string
- $size : string
-
A code as per File::parseSizeString
Return values
string —HTML-safe relative URL, e.g. file/resize/c400x300/123_example.jpg
setCacheResponse()
Set a cached file function response
public
setCacheResponse(string $function, string $filename, mixed $response[, int $ttl = null ]) : void
Parameters
- $function : string
- $filename : string
- $response : mixed
- $ttl : int = null
-
Number of seconds to hold cache for. Defaults to one day
setLogging()
Override the logging.
public
setLogging(bool|callable $logging) : void
By default logging is disabled in production environments. In non-production environments exceptions are logged to the error log.
Provide a callable to log other messages.
Parameters
- $logging : bool|callable
size()
Get the size, in bytes, of the specified file
public
size(string $filename) : int|false
Parameters
- $filename : string
Tags
Return values
int|falsetouch()
Sets access and modification time of file
public
touch(string $filename) : bool
Parameters
- $filename : string
Tags
Return values
boollog()
Log a mesasge or exception.
protected
log(mixed $message) : void
Parameters
- $message : mixed
createFolderPath()
Ensure that a folder path exists for target files.
private
createFolderPath(string $filename) : void
This is for both the base dir and nested directories.
Parameters
- $filename : string