function file_get_content_headers

Examines a file entity and returns appropriate content headers for download.

Parameters

Drupal\file\File $file: A file entity.

Return value

An associative array of headers, as expected by \Symfony\Component\HttpFoundation\StreamedResponse.

1 call to file_get_content_headers()
file_file_download in drupal/core/modules/file/file.module
Implements hook_file_download().

File

drupal/core/modules/file/file.module, line 564
Defines a "managed_file" Form API field and a "file" field for Field module.

Code

function file_get_content_headers(File $file) {
  $name = mime_header_encode($file->filename);
  $type = mime_header_encode($file->filemime);
  return array(
    'Content-Type' => $type,
    'Content-Length' => $file->filesize,
    'Cache-Control' => 'private',
  );
}