Feature: #92518 - Download and filename options added to FileDumpController

See forge#92518

Description

The \TYPO3\CMS\Core\Controller\FileDumpController has been extended with the parameters dl and fn.

  • dl: Force download of the file

  • fn: Use an alternative filename

See the following example on how to create a URI including the new parameters:

// use TYPO3\CMS\Core\Utility\GeneralUtility;
// use TYPO3\CMS\Core\Utility\PathUtility;
// use TYPO3\CMS\Core\Core\Environment;
$queryParameterArray = [
   'eID' => 'dumpFile',
   't' => 'f',
   'f' => $resourceObject->getUid(),
   'dl' => true,
   'fn' => 'alternative-filename.jpg'
];
$queryParameterArray['token'] =
   GeneralUtility::hmac(
      implode('|', $queryParameterArray),
      'resourceStorageDumpFile'
   );

$publicUrl =
   GeneralUtility::locationHeaderUrl(
      PathUtility::getAbsoluteWebPath(Environment::getPublicPath() . '/index.php')
   );
$publicUrl .= '?' . http_build_query($queryParameterArray, '', '&', PHP_QUERY_RFC3986);

This will create a URI from a sys_file record and trigger a download of the file with the alternative filename, using the Content-Disposition: attachment header.

To ease the use of the file dump functionality, also a new ViewHelper is added. See FileViewHelper for further information.

Impact

The dumpFile eID script is now capable of the dl parameter, forcing the download of the corresponding file, as well as the fn parameter, which can be used to define an alternative file name.