Fixes nette3
This commit is contained in:
39
app/modules/Ogg/OggResponse.php
Normal file
39
app/modules/Ogg/OggResponse.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user