/** * Sets the file to stream. * * @param \SplFileInfo|string $file The file to stream * @param string $contentDisposition * @param bool $autoEtag * * @return BinaryFileResponse * * @throws FileException */ public function setFile($file, $contentDisposition = null, $autoEtag = false) { if ($file instanceof File) { $file->setFilesystem($this->filesystem); } else { $file = $this->filesystem->get($file); } if (!$this->filesystem->has($file->getPath())) { throw new FileException('File must be readable.'); } $this->file = $file; if ($autoEtag) { $this->setAutoEtag(); } if ($contentDisposition) { $this->setContentDisposition($contentDisposition); } return $this; }