1 file.inc file_get_content_headers(File $file)

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

Parameters

File $file: A file entity.

Return value

An associative array of headers, as expected by file_transfer().:

Related topics

File

core/includes/file.inc, line 2799
API for handling file uploads and server file management.

Code

function file_get_content_headers(File $file) {
  $type = mime_header_encode($file->filemime);

  return array(
    'Content-Type' => $type,
    'Content-Length' => $file->filesize,
    'Cache-Control' => 'private',
  );
}