'text/plain') * * ### Usage * * {{{ * class ExampleController extends AppController { * public function download() { * $this->viewClass = 'Media'; * $params = array( * 'id' => 'example.zip', * 'name' => 'example', * 'download' => true, * 'extension' => 'zip', * 'path' => APP . 'files' . DS * ); * $this->set($params); * } * } * }}} * * @package Cake.View * @deprecated Deprecated since version 2.3, use CakeResponse::file() instead */ class MediaView extends View { /** * Display or download the given file * * @param string $view Not used * @param string $layout Not used * @return void */ public function render($view = null, $layout = null) { $name = $download = $id = $modified = $path = $cache = $mimeType = $compress = null; extract($this->viewVars, EXTR_OVERWRITE); $path = $path . $id; if (is_array($mimeType)) { $this->response->type($mimeType); } if ($cache) { if (!empty($modified) && !is_numeric($modified)) { $modified = strtotime($modified, time()); } else { $modified = time(); } $this->response->cache($modified, $cache); } else { $this->response->disableCache(); } if ($name !== null) { $name .= '.' . pathinfo($id, PATHINFO_EXTENSION); } $this->response->file($path, compact('name', 'download')); if ($compress) { $this->response->compress(); } $this->response->send(); } }