Feature: #60019 - New SplFileInfo implementation with new mimeTypeGuessers hook¶
See forge#60019
Description¶
A new class \TYPO3\
which extends Spl
is now
available as an API for fetching meta information from files.
Besides the native .. _SplFileInfo API: https://php.net/manual/en/class.splfileinfo.php,
it provides a new method get
to get the mime type of a file, e.g. text/html.
It uses the native PHP function finfo_
and mime_
as a fallback.
Example: Get the MIME type of a file
$fileIdentifier = '/tmp/foo.html';
$fileInfo = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Type\File\FileInfo::class, $fileIdentifier);
echo $fileInfo->getMimeType();
// text/html
Copied!
New Hook 'mimeTypeGuessers'¶
Custom implementations to determine the MIME type can be added with a hook. Register the hook as follows:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuessers']
Copied!