diff options
Diffstat (limited to 'lib/Controller/NavigationController.php')
-rw-r--r-- | lib/Controller/NavigationController.php | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php index c4438e5a..b613fb1e 100644 --- a/lib/Controller/NavigationController.php +++ b/lib/Controller/NavigationController.php @@ -34,6 +34,7 @@ use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse; use daita\MySmallPhpTools\Traits\TArrayTools; use Exception; use OC; +use OC\AppFramework\Http; use OC\User\NoUserException; use OCA\Social\AppInfo\Application; use OCA\Social\Exceptions\AccountAlreadyExistsException; @@ -139,7 +140,7 @@ class NavigationController extends Controller { 'firstrun' => false, 'setup' => false, 'isAdmin' => OC::$server->getGroupManager() - ->isAdmin($this->userId), + ->isAdmin($this->userId), 'cliUrl' => $this->getCliUrl() ] ]; @@ -282,17 +283,61 @@ class NavigationController extends Controller { /** * @NoAdminRequired + * @NoCSRFRequired * * @param string $id * * @return Response */ public function documentGet(string $id): Response { + try { + $mime = ''; + $file = $this->documentService->getFromCache($id, $mime); + + return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]); + + } catch (Exception $e) { + return $this->fail($e); + } + } + + /** + * + * @PublicPage + * @NoCSRFRequired + * + * @param string $id + * + * @return Response + */ + public function documentGetPublic(string $id): Response { try { - $file = $this->documentService->getFromCache($id); + $mime = ''; + $file = $this->documentService->getFromCache($id, $mime, true); - return new FileDisplayResponse($file); + return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]); + } catch (Exception $e) { + return $this->fail($e); + } + } + + + /** + * @NoAdminRequired + * @NoCSRFRequired + * + * @param string $id + * + * @return Response + */ + public function resizedGet(string $id): Response { + + try { + $mime = ''; + $file = $this->documentService->getResizedFromCache($id, $mime); + + return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]); } catch (Exception $e) { return $this->fail($e); } @@ -307,15 +352,17 @@ class NavigationController extends Controller { * * @return Response */ - public function documentGetPublic(string $id): Response { + public function resizedGetPublic(string $id): Response { try { - $file = $this->documentService->getFromCache($id, true); + $mime = ''; + $file = $this->documentService->getResizedFromCache($id, $mime, true); - return new FileDisplayResponse($file); + return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]); } catch (Exception $e) { return $this->fail($e); } } } + |