diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-08-27 21:38:41 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-08-27 21:38:41 +0200 |
commit | 683f0e7f775d6cb0461146ed7b6327de36642e25 (patch) | |
tree | 46afd3da94abdb95ae984261da8696a416b834c1 /apps/theming/lib | |
parent | 73bc108451169aa8ba95eba3749c6450de2ded2e (diff) | |
download | nextcloud-server-683f0e7f775d6cb0461146ed7b6327de36642e25.tar.gz nextcloud-server-683f0e7f775d6cb0461146ed7b6327de36642e25.zip |
Use temporary file as cache
Diffstat (limited to 'apps/theming/lib')
-rw-r--r-- | apps/theming/lib/Controller/ThemingController.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index 67300b17c6d..fbb4c904773 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -39,6 +39,7 @@ use OCP\IConfig; use OCP\IL10N; use OCP\IRequest; use OCA\Theming\Util; +use OCP\ITempManager; /** * Class ThemingController @@ -60,6 +61,8 @@ class ThemingController extends Controller { private $config; /** @var IRootFolder */ private $rootFolder; + /** @var ITempManager */ + private $tempManager; /** * ThemingController constructor. @@ -72,6 +75,7 @@ class ThemingController extends Controller { * @param ITimeFactory $timeFactory * @param IL10N $l * @param IRootFolder $rootFolder + * @param ITempManager $tempManager */ public function __construct( $appName, @@ -81,7 +85,8 @@ class ThemingController extends Controller { Util $util, ITimeFactory $timeFactory, IL10N $l, - IRootFolder $rootFolder + IRootFolder $rootFolder, + ITempManager $tempManager ) { parent::__construct($appName, $request); @@ -91,6 +96,7 @@ class ThemingController extends Controller { $this->l = $l; $this->config = $config; $this->rootFolder = $rootFolder; + $this->tempManager = $tempManager; } /** @@ -199,14 +205,16 @@ class ThemingController extends Controller { // Optimize the image since some people may upload images that will be // either to big or are not progressive rendering. + $tmpFile = $this->tempManager->getTemporaryFile(); if(function_exists('imagescale')) { // FIXME: Once PHP 5.5.0 is a requirement the above check can be removed $image = imagescale($image, 1920); } imageinterlace($image, 1); - imagejpeg($image, $target->fopen('w'), 75); + imagejpeg($image, $tmpFile, 75); imagedestroy($image); + stream_copy_to_stream(fopen($tmpFile, 'r'), $target->fopen('w')); $this->template->set('backgroundMime', $newBackgroundLogo['type']); $name = $newBackgroundLogo['name']; } |