ResourceStorage implements ResourceStorageInterface

A "mount point" inside the TYPO3 file handling.

A "storage" object handles

  • abstraction to the driver
  • permissions (from the driver, and from the user, + capabilities)
  • an entry point for files, folders, and for most other operations

== Driver entry point The driver itself, that does the actual work on the file system, is inside the storage but completely shadowed by the storage, as the storage also handles the abstraction to the driver

The storage can be on the local system, but can also be on a remote system. The combination of driver + configurable capabilities (storage is read-only e.g.) allows for flexible uses.

== Permission system As all requests have to run through the storage, the storage knows about the permissions of a BE/FE user, the file permissions / limitations of the driver and has some configurable capabilities. Additionally, a BE user can use "filemounts" (known from previous installations) to limit his/her work-zone to only a subset (identifier and its subfolders/subfolders) of the user itself.

Check 1: "User Permissions" [is the user allowed to write a file) [is the user allowed to write a file] Check 2: "File Mounts" of the User (act as subsets / filters to the identifiers) [is the user allowed to do something in this folder?] Check 3: "Capabilities" of Storage (then: of Driver) [is the storage/driver writable?] Check 4: "File permissions" of the Driver [is the folder writable?]

Table of Contents

Interfaces

ResourceStorageInterface
The interface for a resource storage containing all constants

Constants

PROCESSING_FOLDER_LEVELS  = 2
Levels numbers used to generate hashed subfolders in the processing folder

Properties

$capabilities  : int
The capabilities of this storage as defined in the storage record.
$configuration  : array<string|int, mixed>
The configuration belonging to this storage (decoded from the configuration field).
$driver  : DriverInterface
The storage driver instance belonging to this storage.
$evaluatePermissions  : bool
Whether to check if file or folder is in user mounts and the action is allowed for a user Default is FALSE so that resources are accessible for front end rendering or admins.
$eventDispatcher  : EventDispatcherInterface
$fileAndFolderNameFilters  : array<string|int, mixed>
The filters used for the files and folder names.
$fileMounts  : array<string|int, mixed>
User filemounts, added as an array, and used as filters
$fileProcessingService  : FileProcessingService
$isDefault  : bool
$isOnline  : bool
whether this storage is online or offline in this request
$processingFolder  : Folder|null
$processingFolders  : array<string|int, Folder>
All processing folders of this storage used in any storage
$storageRecord  : array<string|int, mixed>
The database record for this storage
$userPermissions  : array<string|int, mixed>
The file permissions of the user (and their group) merged together and available as an array

Methods

__construct()  : mixed
Constructor for a storage object.
addFile()  : FileInterface
Moves a file from the local filesystem to this storage.
addFileAndFolderNameFilter()  : mixed
addFileMount()  : mixed
Adds a filemount as a "filter" for users to only work on a subset of a storage object
addUploadedFile()  : FileInterface
Adds an uploaded file into the Storage. Previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::file_upload()
autoExtractMetadataEnabled()  : bool
Returns TRUE if auto extracting of metadata is enabled
checkFileActionPermission()  : bool
Checks if a file operation (= action) is allowed on a File/Folder/Storage (= subject).
checkFolderActionPermission()  : bool
Checks if a folder operation (= action) is allowed on a Folder.
checkUserActionPermission()  : bool
Checks if the ACL settings allow for a certain action (is a user allowed to read a file or copy a folder).
copyFile()  : FileInterface
Previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_copy() copies a source file (from any location) in to the target folder, the latter has to be part of this storage
copyFolder()  : Folder
Copies a folder.
countFilesInFolder()  : int
countFoldersInFolder()  : int
createFile()  : FileInterface
Creates a new file
createFolder()  : Folder
Creates a new folder.
deleteFile()  : bool
Previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::deleteFile()
deleteFolder()  : bool
Previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::folder_delete()
getCapabilities()  : int
Returns the capabilities of this storage.
getConfiguration()  : array<string|int, mixed>
Gets the configuration.
getDefaultFolder()  : Folder
Returns the default folder where new files are stored if no other folder is given.
getDriverType()  : string
Gets the driver Type configured for this storage.
getEvaluatePermissions()  : bool
Gets whether the permissions to access or write into this storage should be checked or not.
getFile()  : FileInterface
Gets a file by identifier.
getFileAndFolderNameFilters()  : array<string|int, mixed>
Returns the file and folder name filters used by this storage.
getFileByIdentifier()  : File|ProcessedFile|null
Gets a file object from storage by file identifier If the file is outside of the process folder, it gets indexed and returned as file object afterwards If the file is within processing folder, the file object will be directly returned
getFileContents()  : string
Get contents of a file object
getFileForLocalProcessing()  : string
Copies a file from the storage for local processing.
getFileIdentifiersInFolder()  : array<string|int, mixed>
getFileInfo()  : array<string|int, mixed>
Gets information about a file.
getFileInfoByIdentifier()  : array<string|int, mixed>
Gets information about a file by its identifier.
getFileInFolder()  : File|ProcessedFile|null
Get file from folder
getFileMounts()  : array<string|int, mixed>
Returns all file mounts that are registered with this storage.
getFilesInFolder()  : array<string|int, File>
getFolder()  : Folder|InaccessibleFolder
getFolderIdentifierFromFileIdentifier()  : string
getFolderIdentifiersInFolder()  : array<string|int, mixed>
getFolderInfo()  : array<string|int, mixed>
Retrieves information about a folder
getFolderInFolder()  : Folder|InaccessibleFolder
Returns the Identifier for a folder within a given folder.
getFoldersInFolder()  : array<string|int, Folder>
getImportExportFilter()  : array<int, ImportExportFilter|string>
Returns a filter for files generated by EXT:impexp
getName()  : string
Returns the name of this storage.
getProcessingFolder()  : Folder
Getter function to return the folder where the files can be processed. Does not check for access rights here.
getProcessingFolders()  : array<string|int, Folder>
Get all processing folders that live in this storage
getPublicUrl()  : string|null
Returns a publicly accessible URL for a file.
getResourceFactoryInstance()  : ResourceFactory
getRole()  : string
Gets the role of a folder.
getRootLevelFolder()  : Folder
Returns the folders on the root level of the storage or the first mount point of this storage for this user if $respectFileMounts is set.
getStorageRecord()  : array<string|int, mixed>
Gets the storage record.
getUid()  : int
Returns the UID of this storage.
hasChildren()  : bool
Tells whether there are children in this storage.
hasFile()  : bool
Returns TRUE if the specified file exists
hasFileInFolder()  : bool
Checks if the queried file in the given folder exists
hasFolder()  : bool
Returns TRUE if the specified folder exists.
hasFolderInFolder()  : bool
Checks if the given file exists in the given folder
hashFile()  : string
Creates a (cryptographic) hash for a file.
hashFileByIdentifier()  : string
Creates a (cryptographic) hash for a fileIdentifier.
hashFileIdentifier()  : string
Hashes a file identifier, taking the case sensitivity of the file system into account. This helps mitigating problems with case-insensitive databases.
hasHierarchicalIdentifiers()  : bool
Returns TRUE if this storage stores folder structure in file identifiers.
isBrowsable()  : bool
Returns TRUE if this storage is browsable by a (backend) user of TYPO3.
isDefault()  : bool
isFallbackStorage()  : bool
Returns true if this storage is a virtual storage that provides access to all files in the project root.
isOnline()  : bool
Returns TRUE if this storage is browsable by a (backend) user of TYPO3.
isProcessingFolder()  : bool
Returns TRUE if folder that is in current storage is set as processing folder for one of the existing storages
isPublic()  : bool
Returns TRUE if this storage is publicly available. This is just a configuration option and does not mean that it really *is* public. OTOH a storage that is marked as not publicly available will trigger the file publishing mechanisms of TYPO3.
isWithinFileMountBoundaries()  : bool
Checks if the given subject is within one of the registered user file mounts. If not, working with the file is not permitted for the user.
isWithinFolder()  : bool
Checks if a resource (file or folder) is within the given folder
isWithinProcessingFolder()  : bool
Returns TRUE if the specified file is in a folder that is set a processing for a storage
isWritable()  : bool
Returns TRUE if this storage is writable. This is determined by the driver and the storage configuration; user permissions are not taken into account.
markAsPermanentlyOffline()  : mixed
Blows the "fuse" and marks the storage as offline.
markAsTemporaryOffline()  : mixed
Marks this storage as offline for the next 5 minutes.
moveFile()  : FileInterface
Moves a $file into a $targetFolder the target folder has to be part of this storage
moveFolder()  : Folder
Moves a folder. If you want to move a folder from this storage to another one, call this method on the target storage, otherwise you will get an exception.
processFile()  : ProcessedFile
Passes a file to the File Processing Services and returns the resulting ProcessedFile object.
renameFile()  : FileInterface
Previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_rename()
renameFolder()  : Folder
Previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::folder_move()
replaceFile()  : FileInterface
Replaces a file with a local file (e.g. a freshly uploaded file)
resetFileAndFolderNameFiltersToDefault()  : mixed
Resets the file and folder name filters to the default values defined in the TYPO3 configuration.
sanitizeFileName()  : string
Clean up a fileName from not allowed characters
searchFiles()  : FileSearchResultInterface
Search for files in a storage based on given restrictions and a possibly given folder.
setConfiguration()  : mixed
Sets the configuration.
setDefault()  : mixed
setDriver()  : ResourceStorage
Sets the storage that belongs to this storage.
setEvaluatePermissions()  : mixed
Sets whether the permissions to access or write into this storage should be checked or not.
setFileAndFolderNameFilters()  : $this
setFileContents()  : int
Set contents of a file object.
setUserPermissions()  : mixed
Sets the user permissions of the storage.
streamFile()  : ResponseInterface
Returns a PSR-7 Response which can be used to stream the requested file
unsetFileAndFolderNameFilters()  : mixed
Unsets the file and folder name filters, thus making this storage return unfiltered filelists.
updateProcessedFile()  : FileInterface
Updates a processed file with a new file from the local filesystem.
usesCaseSensitiveIdentifiers()  : bool
Returns TRUE if the identifiers used by this storage are case-sensitive.
assureFileAddPermissions()  : mixed
Checks if a file/user has the permission to be written to a Folder/Storage.
assureFileCopyPermissions()  : mixed
Check if a file has the permission to be copied on a File/Folder/Storage, if not throw an exception
assureFileDeletePermissions()  : mixed
Assures delete permission for given file.
assureFileMovePermissions()  : mixed
Checks for permissions to move a file.
assureFileReadPermission()  : mixed
Assures read permission for given file.
assureFileRenamePermissions()  : mixed
Checks for permissions to rename a file.
assureFileReplacePermissions()  : mixed
Assure replace permission for given file.
assureFileUploadPermissions()  : mixed
Checks if a file has the permission to be uploaded to a Folder/Storage.
assureFileWritePermissions()  : mixed
Assures write permission for given file.
assureFolderCopyPermissions()  : mixed
Check if a file has the permission to be copied on a File/Folder/Storage, if not throw an exception
assureFolderDeletePermission()  : mixed
Assures delete permission for given folder.
assureFolderMovePermissions()  : mixed
Check if a file has the permission to be copied on a File/Folder/Storage, if not throw an exception
assureFolderReadPermission()  : mixed
Assures read permission for given folder.
checkFileExtensionPermission()  : bool
If the fileName is given, checks it against the TYPO3_CONF_VARS[BE][fileDenyPattern] + and if the file extension is allowed.
checkValidFileExtension()  : bool
Check file extension of an existing file against the current file deny pattern.
copyFolderBetweenStorages()  : mixed
Copies a folder between storages.
createFolderObject()  : Folder
Creates a folder to directly access (a part of) a storage.
getAllFileObjectsInFolder()  : array<string|int, File>
Returns an array with all file objects in a folder and its subfolders, with the file identifiers as keys.
getBackendUser()  : BackendUserAuthentication
Returns the current BE user.
getDriver()  : DriverInterface
Returns the driver object belonging to this storage.
getFileFactory()  : ResourceFactory
getFileIndexRepository()  : FileIndexRepository
getFileProcessingService()  : FileProcessingService
getIndexer()  : Indexer
Gets the Indexer.
getNamesForNestedProcessingFolder()  : array<string|int, string>
Generates appropriate hashed sub-folder path for a given file identifier
getNearestRecyclerFolder()  : Folder|null
Get the nearest Recycler folder for given file
getNestedProcessingFolder()  : Folder
Getter function to return the the file's corresponding hashed subfolder of the processed folder
getProcessedFileRepository()  : ProcessedFileRepository
getPseudoStream()  : ResponseInterface
Wrap DriverInterface::dumpFileContents into a SelfEmittableStreamInterface
getUniqueName()  : string
Returns the destination path/fileName of a unique fileName/foldername in that path.
hasCapability()  : bool
Returns TRUE if this storage has the given capability.
moveFolderBetweenStorages()  : mixed
Moves the given folder from a different storage to the target folder in this storage.

Constants

PROCESSING_FOLDER_LEVELS

Levels numbers used to generate hashed subfolders in the processing folder

public mixed PROCESSING_FOLDER_LEVELS = 2

Properties

$capabilities

The capabilities of this storage as defined in the storage record.

protected int $capabilities

Also see the CAPABILITY_* constants below

$configuration

The configuration belonging to this storage (decoded from the configuration field).

protected array<string|int, mixed> $configuration

$evaluatePermissions

Whether to check if file or folder is in user mounts and the action is allowed for a user Default is FALSE so that resources are accessible for front end rendering or admins.

protected bool $evaluatePermissions = false

$eventDispatcher

protected EventDispatcherInterface $eventDispatcher

$fileAndFolderNameFilters

The filters used for the files and folder names.

protected array<string|int, mixed> $fileAndFolderNameFilters = []

$fileMounts

User filemounts, added as an array, and used as filters

protected array<string|int, mixed> $fileMounts = []

$isDefault

protected bool $isDefault = false

$isOnline

whether this storage is online or offline in this request

protected bool $isOnline

$processingFolders

All processing folders of this storage used in any storage

protected array<string|int, Folder> $processingFolders

$storageRecord

The database record for this storage

protected array<string|int, mixed> $storageRecord

$userPermissions

The file permissions of the user (and their group) merged together and available as an array

protected array<string|int, mixed> $userPermissions = []

Methods

__construct()

Constructor for a storage object.

public __construct(DriverInterface $driver, array<string|int, mixed> $storageRecord[, EventDispatcherInterface|null $eventDispatcher = null ]) : mixed
Parameters
$driver : DriverInterface
$storageRecord : array<string|int, mixed>

The storage record row from the database

$eventDispatcher : EventDispatcherInterface|null = null

addFile()

Moves a file from the local filesystem to this storage.

public addFile(string $localFilePath, Folder $targetFolder[, string $targetFileName = '' ][, string $conflictMode = DuplicationBehavior::RENAME ][, bool $removeOriginal = true ]) : FileInterface
Parameters
$localFilePath : string

The file on the server's hard disk to add

$targetFolder : Folder

The target folder where the file should be added

$targetFileName : string = ''

The name of the file to be add, If not set, the local file name is used

$conflictMode : string = DuplicationBehavior::RENAME

a value of the DuplicationBehavior enumeration

$removeOriginal : bool = true

if set the original file will be removed after successful operation

Tags
throws
InvalidArgumentException
throws
ExistingTargetFileNameException
Return values
FileInterface

addFileAndFolderNameFilter()

public addFileAndFolderNameFilter(callable $filter) : mixed
Parameters
$filter : callable

addFileMount()

Adds a filemount as a "filter" for users to only work on a subset of a storage object

public addFileMount(string $folderIdentifier[, array<string|int, mixed> $additionalData = [] ]) : mixed
Parameters
$folderIdentifier : string
$additionalData : array<string|int, mixed> = []
Tags
throws
FolderDoesNotExistException

addUploadedFile()

Adds an uploaded file into the Storage. Previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::file_upload()

public addUploadedFile(array<string|int, mixed> $uploadedFileData[, Folder|null $targetFolder = null ][, string|null $targetFileName = null ][, string $conflictMode = DuplicationBehavior::CANCEL ]) : FileInterface
Parameters
$uploadedFileData : array<string|int, mixed>

contains information about the uploaded file given by $_FILES['file1']

$targetFolder : Folder|null = null

the target folder

$targetFileName : string|null = null

the file name to be written

$conflictMode : string = DuplicationBehavior::CANCEL

a value of the DuplicationBehavior enumeration

Return values
FileInterface

The file object

autoExtractMetadataEnabled()

Returns TRUE if auto extracting of metadata is enabled

public autoExtractMetadataEnabled() : bool
Return values
bool

checkFileActionPermission()

Checks if a file operation (= action) is allowed on a File/Folder/Storage (= subject).

public checkFileActionPermission(string $action, FileInterface $file) : bool

This method, by design, does not throw exceptions or do logging. Besides the usage from other methods in this class, it is also used by the Filelist UI to check whether an action is allowed and whether action related UI elements should thus be shown (move icon, edit icon, etc.)

Parameters
$action : string

action, can be read, write, delete, editMeta

$file : FileInterface
Return values
bool

checkFolderActionPermission()

Checks if a folder operation (= action) is allowed on a Folder.

public checkFolderActionPermission(string $action[, Folder|null $folder = null ]) : bool

This method, by design, does not throw exceptions or do logging. See the checkFileActionPermission() method above for the reasons.

Parameters
$action : string
$folder : Folder|null = null
Return values
bool

checkUserActionPermission()

Checks if the ACL settings allow for a certain action (is a user allowed to read a file or copy a folder).

public checkUserActionPermission(string $action, string $type) : bool
Parameters
$action : string
$type : string

either File or Folder

Return values
bool

copyFile()

Previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_copy() copies a source file (from any location) in to the target folder, the latter has to be part of this storage

public copyFile(FileInterface $file, Folder $targetFolder[, string $targetFileName = null ][, string $conflictMode = DuplicationBehavior::RENAME ]) : FileInterface
Parameters
$file : FileInterface
$targetFolder : Folder
$targetFileName : string = null

an optional destination fileName

$conflictMode : string = DuplicationBehavior::RENAME

a value of the DuplicationBehavior enumeration

Tags
throws
Exception|AbstractFileOperationException
throws
ExistingTargetFileNameException
Return values
FileInterface

copyFolder()

Copies a folder.

public copyFolder(FolderInterface $folderToCopy, FolderInterface $targetParentFolder[, string $newFolderName = null ][, string $conflictMode = DuplicationBehavior::RENAME ]) : Folder
Parameters
$folderToCopy : FolderInterface

The folder to copy

$targetParentFolder : FolderInterface

The target folder

$newFolderName : string = null
$conflictMode : string = DuplicationBehavior::RENAME

a value of the DuplicationBehavior enumeration

Tags
throws
InvalidTargetFolderException
Return values
Folder

The new (copied) folder object

createFolder()

Creates a new folder.

public createFolder(string $folderName[, Folder|null $parentFolder = null ]) : Folder

previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_newfolder()

Parameters
$folderName : string

The new folder name

$parentFolder : Folder|null = null

(optional) the parent folder to create the new folder inside of. If not given, the root folder is used

Tags
throws
ExistingTargetFolderException
throws
InsufficientFolderAccessPermissionsException
throws
InsufficientFolderWritePermissionsException
throws
Exception
Return values
Folder

getConfiguration()

Gets the configuration.

public getConfiguration() : array<string|int, mixed>
Return values
array<string|int, mixed>

getDefaultFolder()

Returns the default folder where new files are stored if no other folder is given.

public getDefaultFolder() : Folder
Return values
Folder

getDriverType()

Gets the driver Type configured for this storage.

public getDriverType() : string
Return values
string

getEvaluatePermissions()

Gets whether the permissions to access or write into this storage should be checked or not.

public getEvaluatePermissions() : bool
Return values
bool

$evaluatePermissions

getFileAndFolderNameFilters()

Returns the file and folder name filters used by this storage.

public getFileAndFolderNameFilters() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFileByIdentifier()

Gets a file object from storage by file identifier If the file is outside of the process folder, it gets indexed and returned as file object afterwards If the file is within processing folder, the file object will be directly returned

public getFileByIdentifier(string $fileIdentifier) : File|ProcessedFile|null
Parameters
$fileIdentifier : string
Return values
File|ProcessedFile|null

getFileForLocalProcessing()

Copies a file from the storage for local processing.

public getFileForLocalProcessing(FileInterface $fileObject[, bool $writable = true ]) : string
Parameters
$fileObject : FileInterface
$writable : bool = true
Return values
string

Path to local file (either original or copied to some temporary local location)

getFileIdentifiersInFolder()

public getFileIdentifiersInFolder(string $folderIdentifier[, bool $useFilters = true ][, bool $recursive = false ]) : array<string|int, mixed>
Parameters
$folderIdentifier : string
$useFilters : bool = true
$recursive : bool = false
Return values
array<string|int, mixed>

getFileInfo()

Gets information about a file.

public getFileInfo(FileInterface $fileObject) : array<string|int, mixed>
Parameters
$fileObject : FileInterface
Internal
Return values
array<string|int, mixed>

getFileInfoByIdentifier()

Gets information about a file by its identifier.

public getFileInfoByIdentifier(string $identifier[, array<string|int, mixed> $propertiesToExtract = [] ]) : array<string|int, mixed>
Parameters
$identifier : string
$propertiesToExtract : array<string|int, mixed> = []
Internal
Return values
array<string|int, mixed>

getFileMounts()

Returns all file mounts that are registered with this storage.

public getFileMounts() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFilesInFolder()

public getFilesInFolder(Folder $folder[, int $start = 0 ][, int $maxNumberOfItems = 0 ][, bool $useFilters = true ][, bool $recursive = false ][, string $sort = '' ][, bool $sortRev = false ]) : array<string|int, File>
Parameters
$folder : Folder
$start : int = 0
$maxNumberOfItems : int = 0
$useFilters : bool = true
$recursive : bool = false
$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Tags
throws
InsufficientFolderAccessPermissionsException
Return values
array<string|int, File>

getFolderIdentifierFromFileIdentifier()

public getFolderIdentifierFromFileIdentifier(string $fileIdentifier) : string
Parameters
$fileIdentifier : string
Return values
string

getFolderIdentifiersInFolder()

public getFolderIdentifiersInFolder(string $folderIdentifier[, bool $useFilters = true ][, bool $recursive = false ]) : array<string|int, mixed>
Parameters
$folderIdentifier : string
$useFilters : bool = true
$recursive : bool = false
Return values
array<string|int, mixed>

getFolderInfo()

Retrieves information about a folder

public getFolderInfo(Folder $folder) : array<string|int, mixed>
Parameters
$folder : Folder
Return values
array<string|int, mixed>

getFoldersInFolder()

public getFoldersInFolder(Folder $folder[, int $start = 0 ][, int $maxNumberOfItems = 0 ][, bool $useFilters = true ][, bool $recursive = false ][, string $sort = '' ][, bool $sortRev = false ]) : array<string|int, Folder>
Parameters
$folder : Folder
$start : int = 0
$maxNumberOfItems : int = 0
$useFilters : bool = true
$recursive : bool = false
$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Return values
array<string|int, Folder>

getName()

Returns the name of this storage.

public getName() : string
Return values
string

getProcessingFolder()

Getter function to return the folder where the files can be processed. Does not check for access rights here.

public getProcessingFolder([File|null $file = null ]) : Folder
Parameters
$file : File|null = null

Specific file you want to have the processing folder for

Return values
Folder

getProcessingFolders()

Get all processing folders that live in this storage

public getProcessingFolders() : array<string|int, Folder>
Return values
array<string|int, Folder>

getPublicUrl()

Returns a publicly accessible URL for a file.

public getPublicUrl(ResourceInterface $resourceObject[, 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
$resourceObject : ResourceInterface

The file or folder object

$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 missing or deleted, the generated url otherwise

getRole()

Gets the role of a folder.

public getRole(FolderInterface $folder) : string
Parameters
$folder : FolderInterface

Folder object to get the role from

Return values
string

The role the folder has

getRootLevelFolder()

Returns the folders on the root level of the storage or the first mount point of this storage for this user if $respectFileMounts is set.

public getRootLevelFolder([bool $respectFileMounts = true ]) : Folder
Parameters
$respectFileMounts : bool = true
Return values
Folder

getStorageRecord()

Gets the storage record.

public getStorageRecord() : array<string|int, mixed>
Return values
array<string|int, mixed>

getUid()

Returns the UID of this storage.

public getUid() : int
Return values
int

hasChildren()

Tells whether there are children in this storage.

public hasChildren() : bool
Return values
bool

hasFile()

Returns TRUE if the specified file exists

public hasFile(string $identifier) : bool
Parameters
$identifier : string
Return values
bool

hasFileInFolder()

Checks if the queried file in the given folder exists

public hasFileInFolder(string $fileName, Folder $folder) : bool
Parameters
$fileName : string
$folder : Folder
Return values
bool

hasFolder()

Returns TRUE if the specified folder exists.

public hasFolder(string $identifier) : bool
Parameters
$identifier : string
Return values
bool

hasFolderInFolder()

Checks if the given file exists in the given folder

public hasFolderInFolder(string $folderName, Folder $folder) : bool
Parameters
$folderName : string
$folder : Folder
Return values
bool

hashFileByIdentifier()

Creates a (cryptographic) hash for a fileIdentifier.

public hashFileByIdentifier(string $fileIdentifier, string $hash) : string
Parameters
$fileIdentifier : string
$hash : string
Tags
throws
InvalidHashException
Return values
string

hashFileIdentifier()

Hashes a file identifier, taking the case sensitivity of the file system into account. This helps mitigating problems with case-insensitive databases.

public hashFileIdentifier(string|FileInterface $file) : string
Parameters
$file : string|FileInterface
Return values
string

hasHierarchicalIdentifiers()

Returns TRUE if this storage stores folder structure in file identifiers.

public hasHierarchicalIdentifiers() : bool
Return values
bool

isBrowsable()

Returns TRUE if this storage is browsable by a (backend) user of TYPO3.

public isBrowsable() : bool
Return values
bool

isDefault()

public isDefault() : bool
Return values
bool

isFallbackStorage()

Returns true if this storage is a virtual storage that provides access to all files in the project root.

public isFallbackStorage() : bool
Internal
Return values
bool

isOnline()

Returns TRUE if this storage is browsable by a (backend) user of TYPO3.

public isOnline() : bool
Return values
bool

isProcessingFolder()

Returns TRUE if folder that is in current storage is set as processing folder for one of the existing storages

public isProcessingFolder(Folder $folder) : bool
Parameters
$folder : Folder
Return values
bool

isPublic()

Returns TRUE if this storage is publicly available. This is just a configuration option and does not mean that it really *is* public. OTOH a storage that is marked as not publicly available will trigger the file publishing mechanisms of TYPO3.

public isPublic() : bool
Return values
bool

isWithinFileMountBoundaries()

Checks if the given subject is within one of the registered user file mounts. If not, working with the file is not permitted for the user.

public isWithinFileMountBoundaries(ResourceInterface $subject[, bool $checkWriteAccess = false ]) : bool
Parameters
$subject : ResourceInterface

file or folder

$checkWriteAccess : bool = false

If true, it is not only checked if the subject is within the file mount but also whether it isn't a read only file mount

Return values
bool

isWithinProcessingFolder()

Returns TRUE if the specified file is in a folder that is set a processing for a storage

public isWithinProcessingFolder(string $identifier) : bool
Parameters
$identifier : string
Return values
bool

isWritable()

Returns TRUE if this storage is writable. This is determined by the driver and the storage configuration; user permissions are not taken into account.

public isWritable() : bool
Return values
bool

markAsPermanentlyOffline()

Blows the "fuse" and marks the storage as offline.

public markAsPermanentlyOffline() : mixed

Can only be modified by an admin.

Typically, this is only done if the configuration is wrong.

markAsTemporaryOffline()

Marks this storage as offline for the next 5 minutes.

public markAsTemporaryOffline() : mixed

Non-permanent: This typically happens for remote storages that are "flaky" and not available all the time.

moveFile()

Moves a $file into a $targetFolder the target folder has to be part of this storage

public moveFile(FileInterface $file, Folder $targetFolder[, string $targetFileName = null ][, string $conflictMode = DuplicationBehavior::RENAME ]) : FileInterface

previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_move()

Parameters
$file : FileInterface
$targetFolder : Folder
$targetFileName : string = null

an optional destination fileName

$conflictMode : string = DuplicationBehavior::RENAME

a value of the DuplicationBehavior enumeration

Tags
throws
ExistingTargetFileNameException
throws
RuntimeException
Return values
FileInterface

moveFolder()

Moves a folder. If you want to move a folder from this storage to another one, call this method on the target storage, otherwise you will get an exception.

public moveFolder(Folder $folderToMove, Folder $targetParentFolder[, string $newFolderName = null ][, string $conflictMode = DuplicationBehavior::RENAME ]) : Folder
Parameters
$folderToMove : Folder

The folder to move.

$targetParentFolder : Folder

The target parent folder

$newFolderName : string = null
$conflictMode : string = DuplicationBehavior::RENAME

a value of the DuplicationBehavior enumeration

Tags
throws
Exception|Exception
throws
InvalidArgumentException
throws
InvalidTargetFolderException
Return values
Folder

processFile()

Passes a file to the File Processing Services and returns the resulting ProcessedFile object.

public processFile(FileInterface $fileObject, string $context, array<string|int, mixed> $configuration) : ProcessedFile
Parameters
$fileObject : FileInterface

The file object

$context : string
$configuration : array<string|int, mixed>
Tags
throws
InvalidArgumentException
Return values
ProcessedFile

renameFolder()

Previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::folder_move()

public renameFolder(Folder $folderObject, string $newName) : Folder
Parameters
$folderObject : Folder
$newName : string
Tags
throws
Exception
throws
InvalidArgumentException
Return values
Folder

resetFileAndFolderNameFiltersToDefault()

Resets the file and folder name filters to the default values defined in the TYPO3 configuration.

public resetFileAndFolderNameFiltersToDefault() : mixed

sanitizeFileName()

Clean up a fileName from not allowed characters

public sanitizeFileName(string $fileName[, Folder|null $targetFolder = null ]) : string
Parameters
$fileName : string

The name of the file to be sanitized

$targetFolder : Folder|null = null

The target folder where the file is located or should be added

Return values
string

setConfiguration()

Sets the configuration.

public setConfiguration(array<string|int, mixed> $configuration) : mixed
Parameters
$configuration : array<string|int, mixed>

setDefault()

public setDefault(bool $isDefault) : mixed
Parameters
$isDefault : bool

setEvaluatePermissions()

Sets whether the permissions to access or write into this storage should be checked or not.

public setEvaluatePermissions(bool $evaluatePermissions) : mixed
Parameters
$evaluatePermissions : bool

setFileAndFolderNameFilters()

public setFileAndFolderNameFilters(array<string|int, mixed> $filters) : $this
Parameters
$filters : array<string|int, mixed>
Return values
$this

setUserPermissions()

Sets the user permissions of the storage.

public setUserPermissions(array<string|int, mixed> $userPermissions) : mixed
Parameters
$userPermissions : array<string|int, mixed>

streamFile()

Returns a PSR-7 Response which can be used to stream the requested file

public streamFile(FileInterface $file[, bool $asDownload = false ][, string|null $alternativeFilename = null ][, string|null $overrideMimeType = null ]) : ResponseInterface
Parameters
$file : FileInterface
$asDownload : bool = false

If set Content-Disposition attachment is sent, inline otherwise

$alternativeFilename : string|null = null

the filename for the download (if $asDownload is set)

$overrideMimeType : string|null = null

If set this will be used as Content-Type header instead of the automatically detected mime type.

Return values
ResponseInterface

unsetFileAndFolderNameFilters()

Unsets the file and folder name filters, thus making this storage return unfiltered filelists.

public unsetFileAndFolderNameFilters() : mixed

updateProcessedFile()

Updates a processed file with a new file from the local filesystem.

public updateProcessedFile(string $localFilePath, ProcessedFile $processedFile[, Folder|null $processingFolder = null ]) : FileInterface
Parameters
$localFilePath : string
$processedFile : ProcessedFile
$processingFolder : Folder|null = null
Internal

use only

Tags
throws
InvalidArgumentException
Return values
FileInterface

usesCaseSensitiveIdentifiers()

Returns TRUE if the identifiers used by this storage are case-sensitive.

public usesCaseSensitiveIdentifiers() : bool
Return values
bool

assureFileAddPermissions()

Checks if a file/user has the permission to be written to a Folder/Storage.

protected assureFileAddPermissions(Folder $targetFolder, string $targetFileName) : mixed

If not, throws an exception.

Parameters
$targetFolder : Folder

The target folder where the file should be written

$targetFileName : string

The file name which should be written into the storage

Tags
throws
InsufficientFolderWritePermissionsException
throws
IllegalFileExtensionException
throws
InsufficientUserPermissionsException

assureFileCopyPermissions()

Check if a file has the permission to be copied on a File/Folder/Storage, if not throw an exception

protected assureFileCopyPermissions(FileInterface $file, Folder $targetFolder, string $targetFileName) : mixed
Parameters
$file : FileInterface
$targetFolder : Folder
$targetFileName : string
Tags
throws
Exception
throws
InsufficientFolderWritePermissionsException
throws
IllegalFileExtensionException
throws
InsufficientFileReadPermissionsException
throws
InsufficientUserPermissionsException

assureFileUploadPermissions()

Checks if a file has the permission to be uploaded to a Folder/Storage.

protected assureFileUploadPermissions(string $localFilePath, Folder $targetFolder, string $targetFileName, int $uploadedFileSize) : mixed

If not, throws an exception.

Parameters
$localFilePath : string

the temporary file name from $_FILES['file1']['tmp_name']

$targetFolder : Folder

The target folder where the file should be uploaded

$targetFileName : string

the destination file name $_FILES['file1']['name']

$uploadedFileSize : int
Tags
throws
InsufficientFolderWritePermissionsException
throws
UploadException
throws
IllegalFileExtensionException
throws
UploadSizeException
throws
InsufficientUserPermissionsException

assureFolderCopyPermissions()

Check if a file has the permission to be copied on a File/Folder/Storage, if not throw an exception

protected assureFolderCopyPermissions(FolderInterface $folderToCopy, FolderInterface $targetParentFolder) : mixed
Parameters
$folderToCopy : FolderInterface
$targetParentFolder : FolderInterface
Tags
throws
Exception
throws
InsufficientFolderWritePermissionsException
throws
IllegalFileExtensionException
throws
InsufficientFileReadPermissionsException
throws
InsufficientUserPermissionsException
throws
RuntimeException

assureFolderMovePermissions()

Check if a file has the permission to be copied on a File/Folder/Storage, if not throw an exception

protected assureFolderMovePermissions(FolderInterface $folderToMove, FolderInterface $targetParentFolder) : mixed
Parameters
$folderToMove : FolderInterface
$targetParentFolder : FolderInterface
Tags
throws
InvalidArgumentException
throws
InsufficientFolderWritePermissionsException
throws
IllegalFileExtensionException
throws
InsufficientFileReadPermissionsException
throws
InsufficientUserPermissionsException
throws
RuntimeException

assureFolderReadPermission()

Assures read permission for given folder.

protected assureFolderReadPermission([Folder|null $folder = null ]) : mixed
Parameters
$folder : Folder|null = null

If a folder is given, mountpoints are checked. If not only user folder read permissions are checked.

Tags
throws
InsufficientFolderAccessPermissionsException

checkFileExtensionPermission()

If the fileName is given, checks it against the TYPO3_CONF_VARS[BE][fileDenyPattern] + and if the file extension is allowed.

protected checkFileExtensionPermission(string $fileName) : bool
Parameters
$fileName : string

full filename

Return values
bool

TRUE if extension/filename is allowed

checkValidFileExtension()

Check file extension of an existing file against the current file deny pattern.

protected checkValidFileExtension(FileInterface $file) : bool
Parameters
$file : FileInterface
Return values
bool

createFolderObject()

Creates a folder to directly access (a part of) a storage.

protected createFolderObject(string $identifier, string $name) : Folder
Parameters
$identifier : string

The path to the folder. Might also be a simple unique string, depending on the storage driver.

$name : string

The name of the folder (e.g. the folder name)

Return values
Folder

getAllFileObjectsInFolder()

Returns an array with all file objects in a folder and its subfolders, with the file identifiers as keys.

protected getAllFileObjectsInFolder(Folder $folder) : array<string|int, File>
Parameters
$folder : Folder
Tags
todo

check if this is a duplicate

Return values
array<string|int, File>

getNamesForNestedProcessingFolder()

Generates appropriate hashed sub-folder path for a given file identifier

protected getNamesForNestedProcessingFolder(string $fileIdentifier, int $levels) : array<string|int, string>
Parameters
$fileIdentifier : string
$levels : int
Return values
array<string|int, string>

getNearestRecyclerFolder()

Get the nearest Recycler folder for given file

protected getNearestRecyclerFolder(FileInterface $file) : Folder|null

Return null if:

  • There is no folder with ROLE_RECYCLER in the rootline of the given File
  • File is a ProcessedFile (we don't know the concept of recycler folders for processedFiles)
  • File is located in a folder with ROLE_RECYCLER
Parameters
$file : FileInterface
Return values
Folder|null

getPseudoStream()

Wrap DriverInterface::dumpFileContents into a SelfEmittableStreamInterface

protected getPseudoStream(FileInterface $file[, bool $asDownload = false ][, string|null $alternativeFilename = null ][, string|null $overrideMimeType = null ]) : ResponseInterface
Parameters
$file : FileInterface
$asDownload : bool = false

If set Content-Disposition attachment is sent, inline otherwise

$alternativeFilename : string|null = null

the filename for the download (if $asDownload is set)

$overrideMimeType : string|null = null

If set this will be used as Content-Type header instead of the automatically detected mime type.

Return values
ResponseInterface

getUniqueName()

Returns the destination path/fileName of a unique fileName/foldername in that path.

protected getUniqueName(FolderInterface $folder, string $theFile[, bool $dontCheckForUnique = false ]) : string

If $theFile exists in $theDest (directory) the file have numbers appended up to $this->maxNumber. Hereafter a unique string will be appended. This function is used by fx. DataHandler when files are attached to records and needs to be uniquely named in the uploads/* folders

Parameters
$folder : FolderInterface
$theFile : string

The input fileName to check

$dontCheckForUnique : bool = false

If set the fileName is returned with the path prepended without checking whether it already existed!

Tags
throws
RuntimeException
see
BasicFileUtility::getUniqueName()
Return values
string

A unique fileName inside $folder, based on $theFile.

hasCapability()

Returns TRUE if this storage has the given capability.

protected hasCapability(int $capability) : bool
Parameters
$capability : int

A capability, as defined in a CAPABILITY_* constant

Return values
bool

moveFolderBetweenStorages()

Moves the given folder from a different storage to the target folder in this storage.

protected moveFolderBetweenStorages(Folder $folderToMove, Folder $targetParentFolder, string $newFolderName) : mixed
Parameters
$folderToMove : Folder
$targetParentFolder : Folder
$newFolderName : string
Tags
throws
NotImplementedMethodException

        
On this page

Search results