public function BinaryFileResponse::setFile

Sets the file to stream.

Parameters

SplFileInfo|string $file The file to stream:

string $contentDisposition:

Boolean $autoEtag:

Boolean $autoLastModified:

Return value

BinaryFileResponse

Throws

FileException

1 call to BinaryFileResponse::setFile()
BinaryFileResponse::__construct in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php
Constructor.

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php, line 76

Class

BinaryFileResponse
BinaryFileResponse represents an HTTP response delivering a file.

Namespace

Symfony\Component\HttpFoundation

Code

public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) {
  $file = new File((string) $file);
  if (!$file
    ->isReadable()) {
    throw new FileException('File must be readable.');
  }
  $this->file = $file;
  if ($autoEtag) {
    $this
      ->setAutoEtag();
  }
  if ($autoLastModified) {
    $this
      ->setAutoLastModified();
  }
  if ($contentDisposition) {
    $this
      ->setContentDisposition($contentDisposition);
  }
  return $this;
}