You are here

function system_file_download in Drupal 10

Implements hook_file_download().

File

core/modules/system/system.module, line 1381
Configuration system that lets administrators modify the workings of the site.

Code

function system_file_download($uri) {
  $core_schemes = [
    'public',
    'private',
    'temporary',
  ];
  $additional_public_schemes = array_diff(Settings::get('file_additional_public_schemes', []), $core_schemes);
  if ($additional_public_schemes) {
    $scheme = StreamWrapperManager::getScheme($uri);
    if (in_array($scheme, $additional_public_schemes, TRUE)) {
      return [
        // Returning any header grants access, and setting the 'Cache-Control'
        // header is appropriate for public files.
        'Cache-Control' => 'public',
      ];
    }
  }
}