PHP Interface Webiny\Component\Storage\File\FileInterface

Show file Open project: Webiny/Framework

Public Methods

Method Description
__construct ( string $key, Storage $storage ) Constructor
delete ( ) : boolean Delete a file
getAbsolutePath ( ) : string Get absolute file path.
getContents ( ) : string | boolean Get file contents
getKey ( ) : string Get file key
getSize ( ) : integer | null Get file size in bytes
getStorage ( ) : Storage Get file storage
getTimeModified ( boolean $asDateTimeObject = false ) : integer | DateTimeObject Get time modified
getUrl ( ) : string Get file public URL
rename ( string $newKey ) : boolean Rename a file
setContents ( mixed $contents, boolean $append = false ) Set file contents (writes contents to storage)
touch ( ) Touch a file (change time modified)

Method Details

__construct() public method

Constructor
public __construct ( string $key, Storage $storage )
$key string File key
$storage Webiny\Component\Storage\Storage Storage to use

delete() public method

Fires an event StorageEvent::FILE_DELETED after the file was deleted.
public delete ( ) : boolean
return boolean

getAbsolutePath() public method

If storage driver does not support absolute paths (cloud storage) returns file key
public getAbsolutePath ( ) : string
return string

getContents() public method

Get file contents
public getContents ( ) : string | boolean
return string | boolean String on success, false if could not read content

getKey() public method

Get file key
public getKey ( ) : string
return string

getSize() public method

Get file size in bytes
public getSize ( ) : integer | null
return integer | null Number of bytes or null

getStorage() public method

Get file storage
public getStorage ( ) : Storage
return Webiny\Component\Storage\Storage

getTimeModified() public method

Get time modified
public getTimeModified ( boolean $asDateTimeObject = false ) : integer | DateTimeObject
$asDateTimeObject boolean
return integer | DateTimeObject UNIX timestamp or DateTimeObject

getUrl() public method

Get file public URL
public getUrl ( ) : string
return string

rename() public method

Fires an event StorageEvent::FILE_RENAMED after the file was renamed.
public rename ( string $newKey ) : boolean
$newKey string New file name
return boolean

setContents() public method

Fires an event StorageEvent::FILE_SAVED after the file content was written.
public setContents ( mixed $contents, boolean $append = false )
$contents mixed
$append boolean

touch() public method

Touch a file (change time modified)
public touch ( )