FileInterface extends ResourceInterface

File Interface

Table of Contents

Methods

delete()  : bool
Deletes this file from its storage. This also means that this object becomes useless.
getContents()  : string
Get the contents of this file
getCreationTime()  : int
Returns the creation time of the file as Unix timestamp
getExtension()  : string
Get the file extension
getForLocalProcessing()  : non-empty-string
Returns a path to a local version of this file to process it locally (e.g. with some system tool).
getHashedIdentifier()  : non-empty-string
getIdentifier()  : string
getMimeType()  : non-empty-string
Get the MIME type of this file
getModificationTime()  : int
Returns the modification time of the file as Unix timestamp
getName()  : string
getNameWithoutExtension()  : string
Returns the basename (the name without extension) of this file.
getParentFolder()  : FolderInterface
getProperty()  : mixed
Get the value of the $key property.
getPublicUrl()  : non-empty-string|null
Returns a publicly accessible URL for this file
getSha1()  : non-empty-string
Returns the Sha1 of this file
getSize()  : int<0, max>
MUST return the size of the file as unsigned int i.e. 0-max.
getStorage()  : ResourceStorage
hasProperty()  : bool
Returns true if the given key exists for this file.
isIndexed()  : bool
Returns TRUE if this file is indexed
rename()  : FileInterface
Renames this file.
setContents()  : $this
Replace the current file contents with the given string.
toArray()  : array<string, mixed>
Returns an array representation of the file.

Methods

delete()

Deletes this file from its storage. This also means that this object becomes useless.

public delete() : bool
Return values
bool

getContents()

Get the contents of this file

public getContents() : string
Return values
string

getCreationTime()

Returns the creation time of the file as Unix timestamp

public getCreationTime() : int
Return values
int

getExtension()

Get the file extension

public getExtension() : string
Return values
string

getForLocalProcessing()

Returns a path to a local version of this file to process it locally (e.g. with some system tool).

public getForLocalProcessing([bool $writable = true ]) : non-empty-string

If the file is normally located on a remote storages, this creates a local copy. If the file is already on the local system, this only makes a new copy if $writable is set to TRUE.

Parameters
$writable : bool = true

Set this to FALSE if you only want to do read operations on the file.

Return values
non-empty-string

getHashedIdentifier()

public getHashedIdentifier() : non-empty-string
Return values
non-empty-string

getIdentifier()

public getIdentifier() : string
Return values
string

getMimeType()

Get the MIME type of this file

public getMimeType() : non-empty-string
Return values
non-empty-string

mime type

getModificationTime()

Returns the modification time of the file as Unix timestamp

public getModificationTime() : int
Return values
int

getName()

public getName() : string
Return values
string

getNameWithoutExtension()

Returns the basename (the name without extension) of this file.

public getNameWithoutExtension() : string
Return values
string

getProperty()

Get the value of the $key property.

public getProperty(non-empty-string $key) : mixed
Parameters
$key : non-empty-string

getPublicUrl()

Returns a publicly accessible URL for this file

public getPublicUrl() : non-empty-string|null

WARNING: Access to the file may be restricted by further means, e.g. some web-based authentication. You have to take care of this yourself.

Return values
non-empty-string|null

NULL if file is missing or deleted, the generated url otherwise

getSha1()

Returns the Sha1 of this file

public getSha1() : non-empty-string
Return values
non-empty-string

getSize()

MUST return the size of the file as unsigned int i.e. 0-max.

public getSize() : int<0, max>

In case of errors, e.g. when the file is deleted or not readable, this method MAY either throw an Exception or return 0.

Return values
int<0, max>

hasProperty()

Returns true if the given key exists for this file.

public hasProperty(non-empty-string $key) : bool
Parameters
$key : non-empty-string
Return values
bool

isIndexed()

Returns TRUE if this file is indexed

public isIndexed() : bool
Return values
bool

rename()

Renames this file.

public rename(non-empty-string $newName[, string|DuplicationBehavior $conflictMode = DuplicationBehavior::RENAME ]) : FileInterface
Parameters
$newName : non-empty-string

The new file name

$conflictMode : string|DuplicationBehavior = DuplicationBehavior::RENAME
Tags
todo

change $conflictMode parameter type to DuplicationBehavior in TYPO3 v14.0

Return values
FileInterface

setContents()

Replace the current file contents with the given string.

public setContents(string $contents) : $this
Parameters
$contents : string
Tags
todo:

Consider to remove this function from the interface, as its implementation in FileInUse could cause unforseen side-effects by setting contents on the original file instead of just on the Usage of the file.

todo:

At the same time, it could be considered whether to make the whole interface a read-only FileInterface, so that all file management and modification functions are removed...

Return values
$this

toArray()

Returns an array representation of the file.

public toArray() : array<string, mixed>

(This is used by the generic listing module vidi when displaying file records.)

Return values
array<string, mixed>

Array of main data of the file. Don't rely on all data to be present here, it's just a selection of the most relevant information.


        
On this page

Search results