Fixes nette3

This commit is contained in:
2022-01-16 21:51:34 +01:00
parent d14b1eccde
commit 849aa6d5b1
8 changed files with 221 additions and 39 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace Dict;
use Nette;
/**
* CSV download response.
* Under New BSD license.
*
* @package Nette\Application\Responses
*/
class OggResponse extends Nette\Object implements Nette\Application\IResponse
{
private $directory;
private $contentType;
private $addHeading;
private $filename;
private $id;
public function __construct($id = null,$filename = null, $basepath = __DIR__ . "/../../www", $addHeading = TRUE,$contentType = 'audio/ogg')
{
$this->contentType = $contentType;
$this->addHeading = $addHeading;
$this->directory = $basepath . "/media/";
$this->filename = $this->directory . "/".$filename;
$this->id = $id;
}
public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
{
$httpResponse->setContentType($this->contentType);
$attachment = 'attachment';
if (!empty($this->id)) {
$attachment .= '; filename="' . $this->id .".ogg" . '"';
}
$httpResponse->setHeader('Content-Disposition', $attachment);
$httpResponse->setHeader('Content-Length', filesize($this->filename));
readfile($this->filename);
}
}