make media directory configurable and check media file for existence

This commit is contained in:
coderkun 2014-02-14 19:25:29 +01:00
commit 3f686005e3
2 changed files with 13 additions and 3 deletions

View file

@ -59,7 +59,8 @@
* @var array
*/
public static $dirs = array(
'locale' => 'locale'
'locale' => 'locale',
'media' => 'media'
);

View file

@ -46,7 +46,13 @@
/**
* TODO Action: index.
* Action: index.
*
* Display a medium without processing.
*
* @throws IdNotFoundException
* @param string $seminaryUrl URL-title of the Seminary
* @param string $mediaUrl URL-name of the medium
*/
public function index($seminaryUrl, $mediaUrl)
{
@ -60,7 +66,10 @@
$this->response->addHeader("Content-type: ".$media['mimetype']."");
// Set filename
$media['filename'] = ROOT.DS.'media'.DS.$media['id'];
$media['filename'] = ROOT.DS.\nre\configs\AppConfig::$dirs['media'].DS.$media['id'];
if(!file_exists($media['filename'])) {
throw new \nre\exceptions\IdNotFoundException($mediaUrl);
}
// Pass data to view