function File::getDownloadHeaders

Examines a file entity and returns content headers for download.

Return value

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

Overrides FileInterface::getDownloadHeaders

File

core/modules/file/src/Entity/File.php, line 306

Class

File
Defines the file entity class.

Namespace

Drupal\file\Entity

Code

public function getDownloadHeaders() : array {
  return [
    'Content-Type' => $this->getMimeType(),
    'Content-Length' => $this->getSize(),
    'Cache-Control' => 'private',
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.