for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace h4kuna\Upload;
use Nette\Application,
Nette\Http;
class Download
{
/** @var IDriver */
private $driver;
/** @var Http\Request */
private $request;
/** @var Http\Response */
private $response;
public function __construct(IDriver $driver, Http\Request $request, Http\Response $response)
$this->driver = $driver;
$this->request = $request;
$this->response = $response;
}
/**
* @param IStoreFile $file
* @param bool $forceDownload
* @return Application\Responses\FileResponse
*/
public function createFileResponse(IStoreFile $file, $forceDownload = TRUE)
return new Application\Responses\FileResponse(
$this->driver->createURI($file),
$file->getName(), $file->getContentType(), $forceDownload);
* @throws FileDownloadFailedException
public function send(IStoreFile $file, $forceDownload = TRUE)
try {
$this->createFileResponse($file, $forceDownload)->send($this->request, $this->response);
} catch (Application\BadRequestException $e) {
throw new FileDownloadFailedException($e->getMessage(), NULL, $e);