Configuring file storages in file-storages.yaml 

navigation-title

File storages

A file storage defines where TYPO3 reads and writes files, with which driver, and with which credentials.

config/system/file-storages.yaml

file-storages.yaml
Scope
project
Path (Composer)
config/system/file-storages.yaml
Path (Classic)
typo3conf/system/file-storages.yaml

You configure the file storages of an installation in the file config/system/file-storages.yaml. In classic mode, the file is typo3conf/system/file-storages.yaml.

There is no backend form for this file. Only the people and tools that maintain config/system/ can change a storage, for example system maintainers, deployment tooling, and upgrade code.

Changed in version 15.0 Breaking: #110762 - File storages are configured in a file instead of the database

Before, file storages were records of the table sys_file_storage, edited in the Content > Records module. The upgrade wizard "Move file storage records to config/system/file-storages.yaml" writes these records into the file. Run it where you can commit the result, usually in the development environment, and deploy the file before you upgrade the production system.

The default file storage without file-storages.yaml 

The file is optional. Without it, TYPO3 uses one local storage with the identifier 1 and the name fileadmin. It points to the directory set in $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']. An installation that needs only this storage needs no file.

Every file that the file abstraction layer handles is in a configured storage. Files of extensions, referenced as EXT: or PKG:, are system resources instead.

Changed in version 15.0 Breaking: #110361 - Remove FAL fallback storage (uid 0)

The virtual fallback storage with the identifier 0, which covered the whole web root, was removed. The upgrade wizard "Migrate files of the removed fallback storage (uid 0)" moves its file records into the storage that contains the file. It marks a record outside all storages as missing and attaches it to the default storage.

Example: A public and a private file storage in file-storages.yaml 

The following file defines the storage fileadmin/ and a second storage for files that the web server must not deliver directly:

config/system/file-storages.yaml
storages:
  1:
    name: fileadmin
    default: true
    configuration:
      basePath: public/fileadmin/
  2:
    name: 'Private documents'
    public: false
    configuration:
      basePath: storage/private/
Copied!

The key of each entry under storages is the identifier of the storage. It is a positive integer, because every reference to a file or folder contains it, from the storage column of the sys_file table to a combined identifier such as 1:/user_upload/. Do not reuse the identifier of a removed storage: file mounts, upload folders in TSconfig, and links can still point to it.

When the file defines more than one storage, exactly one of them must set default: true.

Options of a file storage in file-storages.yaml 

All options are optional.

Name Type Default
string Storage <identifier>
string Local
bool true for a single storage, false otherwise
bool true
bool true
bool true
bool true
bool true
string _processed_/ in the storage
list of strings empty
map empty
name
Type
string
Default
Storage <identifier>

The name of the storage in the backend, for example in the file tree of the Media module.

driver
Type
string
Default
Local

The short name of the driver. The TYPO3 Core provides the driver Local for the local file system. Extensions can register further drivers, for example for a cloud service.

default
Type
bool
Default
true for a single storage, false otherwise

TYPO3 uses the default storage for every operation that does not name a storage.

browsable
Type
bool
Default
true

If false, users cannot browse the storage in the Media module or in the link browser.

public
Type
bool
Default
true

If false, the public URL of a file points to a script of the TYPO3 Core instead of the file itself. The URL looks like index.php?eID=dumpFile&t=f&f=1230&token=135b17c52f5e718b7cc94e44186eb432e0cc6d2f. The class FileDumpController delivers the file. It does not check access itself. Use the PSR-14 event ModifyFileDumpEvent to add the checks.

writable
Type
bool
Default
true

If false, the storage is read-only.

online
Type
bool
Default
true

If false, the storage cannot be accessed in the backend. Use it to switch off a storage on purpose.

When the driver of a storage cannot access its files, for example because a cloud service is not available, TYPO3 marks the storage as offline as well. This state lasts until the caches are flushed. It does not change the file.

autoExtractMetadata
Type
bool
Default
true

If true, TYPO3 extracts the metadata of a file when it adds the file to the storage, see metadata extractors.

processingFolder
Type
string
Default
_processed_/ in the storage

The folder for processed files, such as resized images. A combined identifier such as 2:/processed/ puts them into another storage.

allowedFileExtensions
Type
list of strings
Default
empty

The file extensions that a file needs to enter the storage, for example [jpg, jpeg, png, webp]. A comma-separated string such as 'pdf,docx,xlsx' works as well. An empty list allows every file extension, see Restricting the file extensions of a file storage.

configuration
Type
map
Default
empty

The options of the driver. For the Local driver, see Options of the Local driver. A driver of an extension documents its own options.

Options of the Local driver for file storages 

Name Type
string
string
bool
basePath
Type
string
Required

true

The directory of the storage. The driver uses an absolute path as it is. A relative path starts at the project path, the directory with the composer.json file. In a Composer-based installation, public/fileadmin/ is the directory fileadmin/ in the web root. storage/private/ is a directory next to config/ and var/, outside the web root. In classic mode, the project path and the web root are the same directory.

A storage with a directory below the web root has public URLs. A storage outside the web root needs baseUri, or TYPO3 delivers its files through the file dump script, see public.

A directory outside the project path must be allowed in $GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath']. Otherwise the storage is offline.

config/system/additional.php
<?php

// Configure additional directories outside of the project's folder
// as absolute paths
$GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'] = [
  '/var/shared/documents/',
  '/var/shared/images/',
];
Copied!

See also the security bulletin "Path Traversal in TYPO3 File Abstraction Layer Storages".

Changed in version 15.0 Feature: #110762 - Project-root relative base paths for local storages

Before, a relative path started at the web root and needed the option pathType: relative. A path with this option still starts at the web root.

baseUri
Type
string

The URL of the base path, for example when another host delivers the files. TYPO3 uses it only for a public storage.

caseSensitive
Type
bool

Whether the file system distinguishes upper and lower case in file names. If the option is not set, the driver detects it.

Restricting the file extensions of a file storage 

The option allowedFileExtensions limits which files can enter a storage, for example a storage for images:

config/system/file-storages.yaml (excerpt)
storages:
  4:
    name: Images
    allowedFileExtensions: [jpg, jpeg, png, webp]
    configuration:
      basePath: public/images/
Copied!

ResourceStorage checks the list for each operation that puts a file into the storage or gives a file a new extension:

  • uploading, adding, and creating a file, also replacing a file by an upload
  • copying a file, or a folder with all the visible files it contains
  • moving a file from another storage
  • renaming or moving a file to another extension

A rejected operation throws an IllegalFileExtensionException . The backend shows it as a message, and it shows the allowed file extensions where users add files.

The list does not affect a file that is already in the storage, as long as the file keeps its extension. Users can rename it, move it within the storage, delete it, and replace its content without an upload. A copy of the file is a new file, so TYPO3 rejects it. TYPO3 does not check processed files, such as thumbnails.

The list only guards the operations of ResourceStorage . It is not a filter. Files that reach the storage another way, for example by FTP or a deployment, are indexed, listed, and referenced like any other file. Enforce the restriction where these files are written.

The list never allows more than the global settings do. TYPO3 checks $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] first. The global list of allowed file extensions and the check of the MIME type apply as before, see Security and consistency checks.

To restrict a folder of a storage for some backend users only, use the field of the file mount, see Restricting the file extensions of a file mount.

Environment variables and imports in file-storages.yaml 

TYPO3 reads the file with its YAML loader. Like in the site configuration, you can use %env()% placeholders and imports. Put values that differ between environments into environment variables, for example credentials of a cloud service or an absolute path:

config/system/file-storages.yaml (excerpt)
storages:
  3:
    name: 'Shared assets'
    configuration:
      basePath: '%env(TYPO3_SHARED_ASSETS_PATH)%'
Copied!

TYPO3 keeps the evaluated file in the core cache. A change of the file takes effect at once. After you change an imported file or an environment variable, flush the caches.

Errors in file-storages.yaml 

TYPO3 reads the file in a tolerant way, so that one mistake does not stop every file access of the site. It logs each problem:

  • TYPO3 ignores an unknown option of a storage.
  • A storage with an invalid value, or with a placeholder for an environment variable that is not set, is offline.
  • If several storages are marked as default, the first of them is the default storage. If none is marked, the first storage is.

A YAML syntax error, an identifier that is not a positive integer, or a storage that is not a map of options stops all file access.

Changing file storages from PHP code 

In a console command or in setup code, FileStorageConfigurationWriter adds, replaces, and removes storages in the file. It checks the result and keeps %env()% placeholders of the storages it does not change. Do not write the file during a web request: it fails on a read-only file system and differs between several web servers.

To add a local directory as a storage, call StorageRepository->addLocalStorage() . It returns the identifier of the new storage and never uses an identifier that is still referenced.

To read the normalized options of all storages, use FileStorageConfiguration .

After each change of the file, TYPO3 dispatches the PSR-14 event FileStorageConfigurationChangedEvent.