From f41c7efdbe93ce4b4ffbe39ec00a023f5f91e192 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Wed, 17 Jul 2019 20:34:28 -0100 Subject: 2 sizes available Signed-off-by: Maxence Lange --- lib/Controller/NavigationController.php | 48 ++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'lib/Controller/NavigationController.php') diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php index 331c7701..b9b256a0 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() ] ]; @@ -289,18 +290,17 @@ class NavigationController extends Controller { * @return Response */ public function documentGet(string $id): Response { - try { $file = $this->documentService->getFromCache($id); - return new FileDisplayResponse($file); + return new FileDisplayResponse($file, Http::STATUS_OK); } catch (Exception $e) { return $this->fail($e); } } - /** + * * @PublicPage * @NoCSRFRequired * @@ -319,4 +319,44 @@ class NavigationController extends Controller { } } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * + * @param string $id + * + * @return Response + */ + public function resizedGet(string $id): Response { + + try { + $file = $this->documentService->getResizedFromCache($id); + + return new FileDisplayResponse($file); + } catch (Exception $e) { + return $this->fail($e); + } + } + + + /** + * @PublicPage + * @NoCSRFRequired + * + * @param string $id + * + * @return Response + */ + public function resizedGetPublic(string $id): Response { + + try { + $file = $this->documentService->getResizedFromCache($id, true); + + return new FileDisplayResponse($file); + } catch (Exception $e) { + return $this->fail($e); + } + } + } -- cgit v1.2.3