AbstractFile implements FileInterface
Abstract file representation in the file abstraction layer.
Table of Contents
Interfaces
- FileInterface
- File Interface
Constants
- FILETYPE_APPLICATION = 5
- Any kind of application
- FILETYPE_AUDIO = 3
- Any kind of audio file
- FILETYPE_IMAGE = 2
- Any kind of image
- FILETYPE_TEXT = 1
- Any kind of text
- FILETYPE_UNKNOWN = 0
- any other file
- FILETYPE_VIDEO = 4
- Any kind of video
Properties
- $deleted : bool
- If set to true, this file is regarded as being deleted.
- $identifier : string
- The identifier of this file to identify it on the storage.
- $name : string
- The file name of this file
- $properties : array<string|int, mixed>
- Various file properties
- $storage : ResourceStorage|null
- The storage this file is located in
Methods
- copyTo() : File
- Copies this file into a target folder
- delete() : bool
- Deletes this file from its storage. This also means that this object becomes useless.
- exists() : bool
- Checks if this file exists. This should normally always return TRUE; it might only return FALSE when this object has been created from an index record without checking for.
- getCombinedIdentifier() : string
- Returns a combined identifier of this file, i.e. the storage UID and the folder identifier separated by a colon ":".
- getContents() : string
- Get the contents of this file
- getCreationTime() : int
- Returns the creation time of the file as Unix timestamp
- getExtension() : string
- Get the extension of this file in a lower-case variant
- getForLocalProcessing() : string
- Returns a path to a local version of this file to process it locally (e.g. with some system tool).
- getHashedIdentifier() : string
- Get hashed identifier
- getIdentifier() : string
- Returns the identifier of this file
- getMimeType() : string
- Get the MIME type of this file
- getModificationTime() : int
- Returns the date (as UNIX timestamp) the file was last modified.
- getName() : string
- Returns the name of this file
- getNameWithoutExtension() : string
- Returns the basename (the name without extension) of this file.
- getParentFolder() : FolderInterface
- Returns the parent folder.
- getProperties() : array<string|int, mixed>
- Returns the properties of this object.
- getProperty() : mixed
- Returns a property value
- getPublicUrl() : string|null
- Returns a publicly accessible URL for this file
- getSha1() : string
- Returns the Sha1 of this file
- getSize() : int|null
- Returns the size of this file
- getStorage() : ResourceStorage
- Get the storage this file is located in
- getType() : int
- Returns the fileType of this file basically there are only five main "file types" "audio" "image" "software" "text" "video" "other" see the constants in this class
- getUid() : int
- Returns the uid of this file
- hasProperty() : bool
- Returns true if the given property key exists for this file.
- isDeleted() : bool
- Returns TRUE if this file has been deleted
- isImage() : bool
- Useful to find out if this file can be previewed or resized as image.
- isMediaFile() : bool
- Useful to find out if this file has a file extension based on any of the registered media extensions
- isTextFile() : bool
- Useful to find out if this file can be edited.
- moveTo() : File
- Moves the file into the target folder
- rename() : FileInterface
- Renames this file.
- setContents() : File
- Replace the current file contents with the given string
- setDeleted() : mixed
- Marks this file as deleted. This should only be used inside the File Abstraction Layer, as it is a low-level API method.
- setIdentifier() : File
- Set the identifier of this file
- setStorage() : File
- Sets the storage this file is located in. This is only meant for \TYPO3\CMS\Core\Resource-internal usage; don't use it to move files.
- updateProperties() : mixed
- Updates properties of this object.
Constants
FILETYPE_APPLICATION
Any kind of application
public
mixed
FILETYPE_APPLICATION
= 5
Tags
FILETYPE_AUDIO
Any kind of audio file
public
mixed
FILETYPE_AUDIO
= 3
Tags
FILETYPE_IMAGE
Any kind of image
public
mixed
FILETYPE_IMAGE
= 2
Tags
FILETYPE_TEXT
Any kind of text
public
mixed
FILETYPE_TEXT
= 1
Tags
FILETYPE_UNKNOWN
any other file
public
mixed
FILETYPE_UNKNOWN
= 0
FILETYPE_VIDEO
Any kind of video
public
mixed
FILETYPE_VIDEO
= 4
Tags
Properties
$deleted
If set to true, this file is regarded as being deleted.
protected
bool
$deleted
= false
$identifier
The identifier of this file to identify it on the storage.
protected
string
$identifier
On some drivers, this is the path to the file, but drivers could also just provide any other unique identifier for this file on the specific storage.
$name
The file name of this file
protected
string
$name
$properties
Various file properties
protected
array<string|int, mixed>
$properties
Note that all properties, which only the persisted (indexed) files have are stored in this overall properties array only. The only properties which really exist as object properties of the file object are the storage, the identifier, the fileName and the indexing status.
$storage
The storage this file is located in
protected
ResourceStorage|null
$storage
Methods
copyTo()
Copies this file into a target folder
public
copyTo(Folder $targetFolder[, string $targetFileName = null ][, string $conflictMode = DuplicationBehavior::RENAME ]) : File
Parameters
- $targetFolder : Folder
-
Folder to copy file into.
- $targetFileName : string = null
-
an optional destination fileName
- $conflictMode : string = DuplicationBehavior::RENAME
-
a value of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration
Tags
Return values
File —The new (copied) file.
delete()
Deletes this file from its storage. This also means that this object becomes useless.
public
delete() : bool
Return values
bool —TRUE if deletion succeeded
exists()
Checks if this file exists. This should normally always return TRUE; it might only return FALSE when this object has been created from an index record without checking for.
public
exists() : bool
Return values
bool —TRUE if this file physically exists
getCombinedIdentifier()
Returns a combined identifier of this file, i.e. the storage UID and the folder identifier separated by a colon ":".
public
getCombinedIdentifier() : string
Return values
string —Combined storage and file identifier, e.g. StorageUID:path/and/fileName.png
getContents()
Get the contents of this file
public
getContents() : string
Tags
Return values
string —File contents
getCreationTime()
Returns the creation time of the file as Unix timestamp
public
getCreationTime() : int
Tags
Return values
intgetExtension()
Get the extension of this file in a lower-case variant
public
getExtension() : string
Return values
string —The file extension
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 ]) : 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.
Tags
Return values
stringgetHashedIdentifier()
Get hashed identifier
public
getHashedIdentifier() : string
Return values
stringgetIdentifier()
Returns the identifier of this file
public
getIdentifier() : string
Return values
stringgetMimeType()
Get the MIME type of this file
public
getMimeType() : string
Return values
string —mime type
getModificationTime()
Returns the date (as UNIX timestamp) the file was last modified.
public
getModificationTime() : int
Tags
Return values
intgetName()
Returns the name of this file
public
getName() : string
Return values
stringgetNameWithoutExtension()
Returns the basename (the name without extension) of this file.
public
getNameWithoutExtension() : string
Return values
stringgetParentFolder()
Returns the parent folder.
public
getParentFolder() : FolderInterface
Return values
FolderInterfacegetProperties()
Returns the properties of this object.
public
getProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>getProperty()
Returns a property value
public
getProperty(string $key) : mixed
Parameters
- $key : string
Return values
mixed —Property value
getPublicUrl()
Returns a publicly accessible URL for this file
public
getPublicUrl([bool $relativeToCurrentScript = false ]) : 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.
Parameters
- $relativeToCurrentScript : bool = false
-
Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver). Deprecated since TYPO3 v11, will be removed in TYPO3 v12.0
Return values
string|null —NULL if file is deleted, the generated URL otherwise
getSha1()
Returns the Sha1 of this file
public
getSha1() : string
Tags
Return values
stringgetSize()
Returns the size of this file
public
getSize() : int|null
Tags
Return values
int|null —Returns null if size is not available for the file
getStorage()
Get the storage this file is located in
public
getStorage() : ResourceStorage
Tags
Return values
ResourceStoragegetType()
Returns the fileType of this file basically there are only five main "file types" "audio" "image" "software" "text" "video" "other" see the constants in this class
public
getType() : int
Return values
int —$fileType
getUid()
Returns the uid of this file
public
getUid() : int
Return values
inthasProperty()
Returns true if the given property key exists for this file.
public
hasProperty(string $key) : bool
Parameters
- $key : string
Return values
boolisDeleted()
Returns TRUE if this file has been deleted
public
isDeleted() : bool
Return values
boolisImage()
Useful to find out if this file can be previewed or resized as image.
public
isImage() : bool
Return values
bool —true if File has an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
isMediaFile()
Useful to find out if this file has a file extension based on any of the registered media extensions
public
isMediaFile() : bool
Return values
bool —true if File is a media-extension according to $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext']
isTextFile()
Useful to find out if this file can be edited.
public
isTextFile() : bool
Return values
bool —true if File is a text-based file extension according to $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']
moveTo()
Moves the file into the target folder
public
moveTo(Folder $targetFolder[, string $targetFileName = null ][, string $conflictMode = DuplicationBehavior::RENAME ]) : File
Parameters
- $targetFolder : Folder
-
Folder to move file into.
- $targetFileName : string = null
-
an optional destination fileName
- $conflictMode : string = DuplicationBehavior::RENAME
-
a value of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration
Tags
Return values
File —This file object, with updated properties.
rename()
Renames this file.
public
rename(string $newName[, string $conflictMode = DuplicationBehavior::RENAME ]) : FileInterface
Parameters
- $newName : string
-
The new file name
- $conflictMode : string = DuplicationBehavior::RENAME
Return values
FileInterfacesetContents()
Replace the current file contents with the given string
public
setContents(string $contents) : File
Parameters
- $contents : string
-
The contents to write to the file.
Tags
Return values
File —The file object (allows chaining).
setDeleted()
Marks this file as deleted. This should only be used inside the File Abstraction Layer, as it is a low-level API method.
public
setDeleted() : mixed
setIdentifier()
Set the identifier of this file
public
setIdentifier(string $identifier) : File
Parameters
- $identifier : string
Should only be used by other parts of the File API (e.g. drivers after moving a file)
Return values
FilesetStorage()
Sets the storage this file is located in. This is only meant for \TYPO3\CMS\Core\Resource-internal usage; don't use it to move files.
public
setStorage(ResourceStorage $storage) : File
Parameters
- $storage : ResourceStorage
Should only be used by other parts of the File API (e.g. drivers after moving a file)
Return values
FileupdateProperties()
Updates properties of this object.
public
abstract updateProperties(array<string|int, mixed> $properties) : mixed
This method is used to reconstitute settings from the database into this object after being instantiated.
Parameters
- $properties : array<string|int, mixed>