File Handling
Note
File handling is managed in the EventHandler class \Friends
.
File Data Sources
When writing to the sys_
table, the extension introduces two virtual fields:
- fileData: Base64-encoded file data.
- url: A publicly accessible URL. The file data will be downloaded from this location or handled by an OnlineMediaHelper (such as for YouTube and Vimeo URLs, that are turned into
.youtube
and.vimeo
files).
Note
File uploads are also affected by the Handle Existing Files behavior setting in the Extension Configuration.
Base64-encoded file data
With the extension's default configuration, this example will create the file at fileadmin/
.
{
"sys_file": {
"ExampleRemoteId": {
"fileData": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8...",
"name": "image.png"
}
}
}
The name
field must be supplied and include a file extension.
Publicly accessible URL
Note
When used repeatedly on the same remote ID, the extension will look for If-
and If-
(ETag
) response headers to determine if a file has changed remotely or not. If it has not changed, the file will not be downloaded again. This means it is possible to always supply the URL, but e.g. only rename the file, if that is the only change in the data.
Normal URL
The default behavior is that the file specified in the url
field is downloaded to the download location specified in the persistence-fileuploadfolderpath UserTS configuration parameter.
With the extension's default configuration, this example will download the file at https://
to fileadmin/
.
{
"sys_file": {
"ExampleRemoteId": {
"url": "https://example.com/image.png",
"name": "image.png"
}
}
}
The name
field must be supplied and include a file extension.
URL with OnlineMediaHelper
If an OnlineMediaHelper is registered for the URL, it will take priority over any other file handling.
With the extension's default configuration, this example will create the file fileadmin/
.
{
"sys_file": {
"ExampleRemoteId": {
"url": "https://youtu.be/zpOVYePk6mM",
}
}
}
If the name
field is used, the file will use the name supplied there and the correct extension added if necessary (e.g. .youtube
).
File name sanitation
File names are sanitized using TYPO3's standard sanitation methods, so expect spaces to be replaced with underscores, etc.