src/Leevel/Http/FileResponse.php
public function setFile($file, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true): IResponse
    {
        if ($this->checkFlowControl()) {
            return $this;
        }

        if (!$file instanceof File) {
            if ($file instanceof SplFileInfo || $file instanceof SplFileObject) {
                $file = new File($file->getPathname());
            } else {
                if (!is_readable($file)) {
                    throw new FileException('File must be readable.');
                }

                $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;
    }
public function setFile($file, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true): IResponse
    {
        if ($this->checkFlowControl()) {
            return $this;
        }

        if (!$file instanceof File) {
            if ($file instanceof SplFileInfo || $file instanceof SplFileObject) {
                $file = new File($file->getPathname());
            } else {
                if (!is_readable($file)) {
                    throw new FileException('File must be readable.');
                }

                $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;
    }
设置文件.

@param \SplFileInfo|\SplFileObject|string $file
@param string                             $contentDisposition
@param bool                               $autoEtag
@param bool                               $autoLastModified

@return $this