diff options
author | Robin Appelman <robin@icewind.nl> | 2016-10-27 14:48:42 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2016-11-16 15:30:36 +0100 |
commit | eb21dc2bd33040882eac52e3a768963f20ac3b4a (patch) | |
tree | 442d788124275b6ffc097810309aa0c6fce3479a /apps | |
parent | 4235b18a889cd9d1b306ea410ed8e8ec307730c1 (diff) | |
download | nextcloud-server-eb21dc2bd33040882eac52e3a768963f20ac3b4a.tar.gz nextcloud-server-eb21dc2bd33040882eac52e3a768963f20ac3b4a.zip |
fix theming images when using primary storage
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/theming/lib/Controller/ThemingController.php | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index f274d245887..5dec2a707f1 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -32,9 +32,12 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataDownloadResponse; use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\StreamResponse; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Files\File; use OCP\Files\IRootFolder; +use OCP\Files\NotFoundException; use OCP\IConfig; use OCP\IL10N; use OCP\IRequest; @@ -255,15 +258,17 @@ class ThemingController extends Controller { * @PublicPage * @NoCSRFRequired * - * @return StreamResponse|DataResponse + * @return StreamResponse|NotFoundResponse */ public function getLogo() { - $pathToLogo = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/') . '/themedinstancelogo'; - if(!file_exists($pathToLogo)) { - return new DataResponse(); + try { + /** @var File $file */ + $file = $this->rootFolder->get('themedinstancelogo'); + } catch (NotFoundException $e) { + return new NotFoundResponse(); } - $response = new Http\StreamResponse($pathToLogo); + $response = new Http\StreamResponse($file->fopen('r')); $response->cacheFor(3600); $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); $response->addHeader('Content-Disposition', 'attachment'); @@ -276,15 +281,17 @@ class ThemingController extends Controller { * @PublicPage * @NoCSRFRequired * - * @return StreamResponse|DataResponse + * @return StreamResponse|NotFoundResponse */ public function getLoginBackground() { - $pathToLogo = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/') . '/themedbackgroundlogo'; - if(!file_exists($pathToLogo)) { - return new DataResponse(); + try { + /** @var File $file */ + $file = $this->rootFolder->get('themedbackgroundlogo'); + } catch (NotFoundException $e) { + return new NotFoundResponse(); } - $response = new StreamResponse($pathToLogo); + $response = new StreamResponse($file->fopen('r')); $response->cacheFor(3600); $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); $response->addHeader('Content-Disposition', 'attachment'); |