function file_get_content_headers
Examines a file entity and returns appropriate content headers for download.
Parameters
\Drupal\file\FileInterface $file: A file entity.
Return value
array An associative array of headers, as expected by \Symfony\Component\HttpFoundation\StreamedResponse.
3 calls to file_get_content_headers()
- editor_file_download in core/modules/ editor/ editor.module 
- Implements hook_file_download().
- file_file_download in core/modules/ file/ file.module 
- Implements hook_file_download().
- file_test_file_download in core/modules/ file/ tests/ file_test/ file_test.module 
- Implements hook_file_download().
File
- 
              core/modules/ file/ file.module, line 365 
Code
function file_get_content_headers(FileInterface $file) {
  return [
    'Content-Type' => $file->getMimeType(),
    'Content-Length' => $file->getSize(),
    'Cache-Control' => 'private',
  ];
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
