/** * @param \Base $f3 * @param array $params * @throws \Exception */ public function file($f3, $params) { $file = new \Model\Issue\File(); $file->load($params["id"]); if (!$file->id) { $f3->error(404); return; } $force = true; if (substr($file->content_type, 0, 5) == "image" || $file->content_type == "text/plain") { // Don't force download on image and plain text files // Eventually I'd like to have previews of files some way (more than the existing thumbnails), but for now this is how we do it - Alan $force = false; } if (!$this->_sendFile($file->disk_filename, $file->content_type, $file->filename, $force)) { $f3->error(404); } }
/** * POST /issues/file/undelete * Un-delete a file * * @param \Base $f3 * @throws \Exception */ public function file_undelete($f3) { $file = new \Model\Issue\File(); $file->load($f3->get("POST.id")); $file->deleted_date = null; $file->save(); $this->_printJson($file->cast()); }