Merge pull-request #2891

This commit is contained in:
Frederic Guillot
2016-12-19 22:04:15 -05:00
3 changed files with 49 additions and 0 deletions

View File

@@ -82,6 +82,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
*