diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-12-19 22:04:15 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-12-19 22:04:15 -0500 |
commit | eed51aef63d55d8906f3f0e6c707ef1f1739d5ff (patch) | |
tree | 401e36caaa4e5b7410ec9d3986494248899f3e3b /app/Controller/FileViewerController.php | |
parent | efb786b5c5ab34b9245d5d40d3a3a2810f09a30d (diff) | |
parent | 89feb0ae03c5a492526df077b2a3b382b0428ca8 (diff) |
Merge pull-request #2891
Diffstat (limited to 'app/Controller/FileViewerController.php')
-rw-r--r-- | app/Controller/FileViewerController.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/Controller/FileViewerController.php b/app/Controller/FileViewerController.php index 518f5b0b..3e0182ba 100644 --- a/app/Controller/FileViewerController.php +++ b/app/Controller/FileViewerController.php @@ -83,6 +83,31 @@ class FileViewerController extends BaseController } /** + * Display file in browser + * + * @access public + */ + public function browser() + { + $file = $this->getFile(); + $etag = md5($file['path']); + $this->response->withContentType($this->helper->file->getBrowserViewType($file['name'])); + $this->response->withCache(5 * 86400, $etag); + + if ($this->request->getHeader('If-None-Match') === '"'.$etag.'"') { + $this->response->status(304); + } else { + + try { + $this->response->send(); + $this->objectStorage->output($file['path']); + } catch (ObjectStorageException $e) { + $this->logger->error($e->getMessage()); + } + } + } + + /** * Display image thumbnail * * @access public |