@param string $file
@param string|null $name
@param bool $download

@return ResponseInterface
@throws \LogicException
188630
public function file(string $file, string $name = null, bool $download = true): ResponseInterface
    {
        if (!\is_file($file)) {
            throw new \LogicException("File '$file' doesn't exist.");
        }

        $extension = \substr($file, \strrpos($file, '.') + 1);
        $this->header->set('Content-Type',
            MimeType::getMimeType($extension) ?? 'application/octet-stream'
        );

        $disposition = $download ? Header::DISPOSITION_ATTACHMENT : Header::DISPOSITION_INLINE;
        $this->header->set('Content-Disposition',
            $this->header->makeDisposition($disposition, $name, \basename($file))
        );

        $size = $length = \filesize($file);

        $this->header->set('Accept-Ranges', 'bytes');
        if (\preg_match('#^bytes=(\d*)-(\d*)\z#', $this->request->header('Range'), $matches)) {
            list(, $start, $end) = $matches;

            if ($start === '') {
                $start = \max(0, $size - $end);
                $end = $size - 1;
            } elseif ($end === '' || $end > $size - 1) {
                $end = $size - 1;
            }

            if ($end < $start) {
                return $this->empty(416); // requested range not satisfiable
            }

            $this->setStatus(206);
            $this->header->set('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $size);
            $length = $end - $start + 1;
        } else {
            $this->header->set('Content-Range', 'bytes 0-' . ($size - 1) . '/' . $size);
        }

        $this->header->set('Content-Length', $length);

        $this->app->emitter(
            $this->emitter ?? Emitter\SapiStream::class
        );

        return $this->response(
            Factory::streamFromFile($file, 'rb')
        );
    }
382542
protected function processFile($column, $file, $filename, $name = null)
  {
    if (!is_file($file)) {
      Exception::ThrowError(Exception::FILE_NOT_EXISTS, $file);
    }

    $ext  = strtolower(pathinfo($file, PATHINFO_EXTENSION));
    $size = filesize($file);

    $this->copyFile($file, $this->getFilesPath() . $filename);

    return $this->setSerialized(
      $column,
      array(
        'file'      => $filename,
        'extension' => $ext,
        'size'      => $size,
        'name'      => $name,
      )
    );
  }
1307091
public function download($file, $filename = null, array $headers = [], $disposition = 'attachment')
    {
        $type = mime_content_type($file);

        if ($filename == null) {
            $filename = basename($file);
        }

        $this->addHeader('Content-Disposition', $disposition.'; filename='.$filename);

        $this->addHeader('Content-Type', $type);

        $this->addHeader('Content-Length', filesize($file));

        $this->addHeader('Content-Encoding', 'base64');

        foreach ($headers as $key => $value) {
            $this->addHeader($key, $value);
        }

        $this->download_filename = $file;

        $this->download = true;

        return $this->buildHttpResponse();
    }
892260
public function removeHeader(string $name) : parent
    {
        if ($this->headerSent($file, $line)) {
            throw new \LogicException(sprintf("Headers is already sent in '%s:%s'", $file, $line));
        }

        return parent::removeHeader($name);
    }
996086
public function download(
        $file,
        string $name = null,
        array $headers = [],
        string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT
    ) : BinaryFileResponse {
        $response = new BinaryFileResponse($file, HttpResponse::HTTP_OK, $headers, true, $disposition);

        $response->prepare(HttpRequest::createFromGlobals());

        if ( ! is_null($name)) {
            $response = $response->setContentDisposition(
                $disposition,
                $name,
                iconv('UTF-8', 'ASCII//TRANSLIT', $name)
            );
        }

        return $this->createOnly ? $response : $response->send();
    }
320830
public function getFromInput($name = false)
    {
        if ($name) {
            $this->img       = $_FILES[$name];
            $this->handle    = new Upload($this->img);
            $this->_new_name = $this->s3->sanitizeFilename(uniqid("", true) . $this->handle->file_src_name);
        }
    }
1335461
public function resolveFile($name)
    {
        if($this->getStorageFacility() == null)
            return null;

        return $this->getStorageFacility()->resolveFile($this->getStorageFacilityParams(), $name);
    }
508486
protected function file($file, string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse
    {
        $response = new BinaryFileResponse($file);
        $response->setContentDisposition($disposition, null === $fileName ? $response->getFile()->getFilename() : $fileName);

        return $response;
    }
639531
public function get(string $name): ?ResponseCookieInterface
    {
        if (!isset($this->responseCookies[$name])) {
            return null;
        }

        return $this->responseCookies[$name];
    }
524488
public function getFileParameter($name)
    {
        if (!$this->hasFileParameter($name)) {
            throw new \InvalidArgumentException(sprintf('The file request parameter "%s" does not exist.', $name));
        }

        return $this->fileParameters[$name];
    }
597946
public static function create($name = null, $file = null, $url = null)
    {
        return new static($name, $file, $url);
    }
1353985
public function download($file, $filename = '', $options = array())
    {
        $this->response->download($file, $filename, $options);
    }
867659
public static function file($name, $options = [])
    {
        self::exclure($options);

        return self::input('file', $name, null, $options);
    }
286321
protected function doFilterFile($name /*, $file*/)
    {
        // check include ...
        if (\in_array($name, $this->include['file'], true)) {
            return true;
        }

        // check exclude file ...
        if (\in_array($name, $this->exclude['file'], true)) {
            return false;
        }

        $ext = implode('|', $this->getInclude('ext'));

        // check include ext ...
        if ($ext && preg_match("/\.($ext)$/i", $name)) {
            // have been set custom file Filter
            if ($fileFilter = $this->fileFilter) {
                return $fileFilter($name);
            }

            return true;
        }

        $noExt = implode('|', $this->getExclude('ext'));

        // check exclude ext ...
        if ($noExt && preg_match("/\.($noExt)$/i", $name)) {
            return false;
        }

        // have been set custom file Filter
        if ($fileFilter = $this->fileFilter) {
            return $fileFilter($name);
        }

        return true;
    }
639774
public function attachment(string $file, ?string $name = null)
  {
    $this->attachment[] = ['file' => $file, 'name' => $name];
    return $this;
  }
400202
public function streamDownload($callback, $name = null, array $headers = [], $disposition = 'attachment')
    {
        respondWith(response()->streamDownload($callback, $name, $headers, $disposition ));
    }
639677
public function sendAsDownload($name)
    {

        // Redirect output to a client’s web browser (Excel2007)
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: attachment;filename="' . $name . '.xls"');
        header('Cache-Control: max-age=0');
        // If you're serving to IE 9, then the following may be needed
        header('Cache-Control: max-age=1');
        // If you're serving to IE over SSL, then the following may be needed
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
        header('Pragma: public'); // HTTP/1.0
        $objWriter = \PHPExcel_IOFactory::createWriter($this->excel, 'Excel2007');
        $filePath = Filesystem::allocate(); // Crear un archivo temporal
        $objWriter->save($filePath);
        readfile($filePath);
        unlink($filePath);
    }