function BinaryFileResponse::setFile
Sets the file to stream.
Return value
$this
Throws
1 call to BinaryFileResponse::setFile()
- BinaryFileResponse::__construct in vendor/
symfony/ http-foundation/ BinaryFileResponse.php
File
-
vendor/
symfony/ http-foundation/ BinaryFileResponse.php, line 64
Class
- BinaryFileResponse
- BinaryFileResponse represents an HTTP response delivering a file.
Namespace
Symfony\Component\HttpFoundationCode
public function setFile(\SplFileInfo|string $file, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true) : static {
$isTemporaryFile = $file instanceof \SplTempFileObject;
$this->tempFileObject = $isTemporaryFile ? $file : null;
if (!$file instanceof File) {
if ($file instanceof \SplFileInfo) {
$file = new File($file->getPathname(), !$isTemporaryFile);
}
else {
$file = new File($file);
}
}
if (!$file->isReadable() && !$isTemporaryFile) {
throw new FileException('File must be readable.');
}
$this->file = $file;
if ($autoEtag) {
$this->setAutoEtag();
}
if ($autoLastModified && !$isTemporaryFile) {
$this->setAutoLastModified();
}
if ($contentDisposition) {
$this->setContentDisposition($contentDisposition);
}
return $this;
}