FileRepositoryInterface
interface FileRepositoryInterface (View source)
Performs file system operations and updates database records accordingly.
Methods
Writes a file to the specified destination and creates a file entity.
Copies a file to a new location and adds a file record to the database.
Moves a file to a new location and update the file's database entry.
Loads the first File entity found with the specified URI.
Details
FileInterface
writeData(string $data, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME)
Writes a file to the specified destination and creates a file entity.
FileInterface
copy(FileInterface $source, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME)
Copies a file to a new location and adds a file record to the database.
This function should be used when manipulating files that have records stored in the database. This is a powerful function that in many ways performs like an advanced version of copy().
- Checks if $source and $destination are valid and readable/writable.
- If file already exists in $destination either the call will error out, replace the file or rename the file based on the $replace parameter.
- If the $source and $destination are equal, the behavior depends on the $replace parameter. FileSystemInterface::EXISTS_REPLACE will error out. FileSystemInterface::EXISTS_RENAME will rename the file until the $destination is unique.
- Adds the new file to the files database. If the source file is a temporary file, the resulting file will also be a temporary file. See file_save_upload() for details on temporary files.
FileInterface
move(FileInterface $source, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME)
Moves a file to a new location and update the file's database entry.
- Checks if $source and $destination are valid and readable/writable.
- Performs a file move if $source is not equal to $destination.
- If file already exists in $destination either the call will error out, replace the file or rename the file based on the $replace parameter.
- Adds the new file to the files database.
FileInterface|null
loadByUri(string $uri)
Loads the first File entity found with the specified URI.