file_get_content_headers(FileInterface $file)
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.
File
- core/modules/file/file.module, line 552
- Defines a "managed_file" Form API field and a "file" field for Field module.
Code
1 2 3 4 5 6 7 8 9 | function file_get_content_headers(FileInterface $file ) { $type = Unicode::mimeHeaderEncode( $file ->getMimeType()); return array ( 'Content-Type' => $type , 'Content-Length' => $file ->getSize(), 'Cache-Control' => 'private' , ); } |
Please login to continue.