You are here

function file_get_content_headers in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/file/file.module \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.

2 calls to file_get_content_headers()
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 534
Defines a "managed_file" Form API field and a "file" field for Field module.

Code

function file_get_content_headers(FileInterface $file) {
  $type = Unicode::mimeHeaderEncode($file
    ->getMimeType());
  return array(
    'Content-Type' => $type,
    'Content-Length' => $file
      ->getSize(),
    'Cache-Control' => 'private',
  );
}