]> source.dussan.org Git - nextcloud-server.git/commitdiff
Contacts: Use OC_Cache for contact photo handling instead of temp dir.
authorThomas Tanghus <thomas@tanghus.net>
Tue, 5 Jun 2012 18:30:22 +0000 (20:30 +0200)
committerThomas Tanghus <thomas@tanghus.net>
Tue, 5 Jun 2012 18:34:12 +0000 (20:34 +0200)
apps/contacts/ajax/cropphoto.php
apps/contacts/ajax/currentphoto.php
apps/contacts/ajax/savecrop.php
apps/contacts/ajax/uploadphoto.php
apps/contacts/dynphoto.php [deleted file]
apps/contacts/js/contacts.js
apps/contacts/templates/part.cropphoto.php
apps/contacts/tmpphoto.php [new file with mode: 0644]

index 7b286dbdb5283adf8a07a0fca54a70d8384e8a71..63c9eb8f2d32782fb9fa57748cbaf9cf22c07459 100644 (file)
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 
-$tmp_path = $_GET['tmp_path'];
+$tmpkey = $_GET['tmpkey'];
 $id = $_GET['id'];
-OCP\Util::writeLog('contacts','ajax/cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
+//OCP\Util::writeLog('contacts','ajax/cropphoto.php: tmpkey: '.$tmpkey.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
 $tmpl = new OCP\Template("contacts", "part.cropphoto");
-$tmpl->assign('tmp_path', $tmp_path);
+$tmpl->assign('tmpkey', $tmpkey);
 $tmpl->assign('id', $id);
 $page = $tmpl->fetchPage();
 
index d0654b17d64487b5a1c9e1bf9ad5736771848d81..e4d69eeb878eeeca46cd7aebf6df78ce877bbf0e 100644 (file)
  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
-// Init owncloud
-//require_once('../../../lib/base.php');
 
-// Check if we are a user
 // Firefox and Konqueror tries to download application/json for me.  --Arthur
 OCP\JSON::setContentTypeHeader('text/plain');
 OCP\JSON::checkLoggedIn();
@@ -32,30 +29,24 @@ function bailOut($msg) {
        OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::ERROR);
        exit();
 }
-function debug($msg) {
-       OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::DEBUG);
-}
 
 if (!isset($_GET['id'])) {
        bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
 }
 
-$tmpfname = tempnam(get_temp_dir(), "occOrig");
 $contact = OC_Contacts_App::getContactVCard($_GET['id']);
-$image = new OC_Image();
-if(!$image) {
-       bailOut(OC_Contacts_App::$l10n->t('Error loading image.'));
-}
 // invalid vcard
 if( is_null($contact)) {
        bailOut(OC_Contacts_App::$l10n->t('Error reading contact photo.'));
 } else {
+       $image = new OC_Image();
        if(!$image->loadFromBase64($contact->getAsString('PHOTO'))) {
                $image->loadFromBase64($contact->getAsString('LOGO'));
        }
        if($image->valid()) {
-               if($image->save($tmpfname)) {
-                       OCP\JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpfname)));
+               $tmpkey = 'contact-photo-'.md5($contact->getAsString('FN'));
+               if(OC_Cache::set($tmpkey, $image->data(), 600)) {
+                       OCP\JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpkey)));
                        exit();
                } else {
                        bailOut(OC_Contacts_App::$l10n->t('Error saving temporary file.'));
index e335c76fd9accde743fcd5e663f03124adcc35e3..b3aab6a88101a3f705047e12e0c72786201fb543 100644 (file)
  * You should have received a copy of the GNU Affero General Public
  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
  *
- * TODO: Translatable strings.
  */
 // Check if we are a user
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 
-// foreach ($_POST as $key=>$element) {
-//     OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OCP\Util::DEBUG);
-// }
-
 // Firefox and Konqueror tries to download application/json for me.  --Arthur
 OCP\JSON::setContentTypeHeader('text/plain');
 
@@ -45,88 +40,71 @@ $y1 = (isset($_POST['y1']) && $_POST['y1']) ? $_POST['y1'] : 0;
 //$y2 = isset($_POST['y2']) ? $_POST['y2'] : -1;
 $w = (isset($_POST['w']) && $_POST['w']) ? $_POST['w'] : -1;
 $h = (isset($_POST['h']) && $_POST['h']) ? $_POST['h'] : -1;
-$tmp_path = isset($_POST['tmp_path']) ? $_POST['tmp_path'] : '';
+$tmpkey = isset($_POST['tmpkey']) ? $_POST['tmpkey'] : '';
 $id = isset($_POST['id']) ? $_POST['id'] : '';
 
-if($tmp_path == '') {
-       bailOut('Missing path to temporary file.');
+if($tmpkey == '') {
+       bailOut('Missing key to temporary file.');
 }
 
 if($id == '') {
        bailOut('Missing contact id.');
 }
 
-OCP\Util::writeLog('contacts','savecrop.php: files: '.$tmp_path.'  exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
+OCP\Util::writeLog('contacts','savecrop.php: key: '.$tmpkey, OCP\Util::DEBUG);
 
-if(file_exists($tmp_path)) {
+$data = OC_Cache::get($tmpkey);
+if($data) {
        $image = new OC_Image();
-       if($image->loadFromFile($tmp_path)) {
+       if($image->loadFromdata($data)) {
                $w = ($w != -1 ? $w : $image->width());
                $h = ($h != -1 ? $h : $image->height());
                OCP\Util::writeLog('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OCP\Util::DEBUG);
                if($image->crop($x1, $y1, $w, $h)) {
                        if(($image->width() <= 200 && $image->height() <= 200) || $image->resize(200)) {
-                               $tmpfname = tempnam(get_temp_dir(), "occCropped"); // create a new file because of caching issues.
-                               if($image->save($tmpfname)) {
-                                       unlink($tmp_path);
-                                       $card = OC_Contacts_App::getContactVCard($id);
-                                       if(!$card) {
-                                               unlink($tmpfname);
-                                               bailOut('Error getting contact object.');
-                                       }
-                                       if($card->__isset('PHOTO')) {
-                                               OCP\Util::writeLog('contacts','savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
-                                               $property = $card->__get('PHOTO');
-                                               if(!$property) {
-                                                       unlink($tmpfname);
-                                                       bailOut('Error getting PHOTO property.');
-                                               }
-                                               $property->setValue($image->__toString());
-                                               $property->parameters[] = new Sabre_VObject_Parameter('ENCODING', 'b');
-                                               $property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType());
-                                               $card->__set('PHOTO', $property);
-                                       } else {
-                                               OCP\Util::writeLog('contacts','savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG);
-                                               $card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType()));
-                                       }
-                                       $now = new DateTime;
-                                       $card->setString('REV', $now->format(DateTime::W3C));
-                                       if(!OC_Contacts_VCard::edit($id,$card)) {
-                                               bailOut('Error saving contact.');
+                               $card = OC_Contacts_App::getContactVCard($id);
+                               if(!$card) {
+                                       OC_Cache::remove($tmpkey);
+                                       bailOut(OC_Contacts_App::$l10n->t('Error getting contact object.'));
+                               }
+                               if($card->__isset('PHOTO')) {
+                                       OCP\Util::writeLog('contacts','savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
+                                       $property = $card->__get('PHOTO');
+                                       if(!$property) {
+                                               OC_Cache::remove($tmpkey);
+                                               bailOut(OC_Contacts_App::$l10n->t('Error getting PHOTO property.'));
                                        }
-                                       unlink($tmpfname);
-                                       //$result=array( "status" => "success", 'mime'=>$image->mimeType(), 'tmp'=>$tmp_path);
-                                       $tmpl = new OCP\Template("contacts", "part.contactphoto");
-                                       $tmpl->assign('tmp_path', $tmpfname);
-                                       $tmpl->assign('mime', $image->mimeType());
-                                       $tmpl->assign('id', $id);
-                                       $tmpl->assign('refresh', true);
-                                       $tmpl->assign('width', $image->width());
-                                       $tmpl->assign('height', $image->height());
-                                       $page = $tmpl->fetchPage();
-                                       OCP\JSON::success(array('data' => array('page'=>$page, 'tmp'=>$tmpfname)));
-                                       exit();
+                                       $property->setValue($image->__toString());
+                                       $property->parameters[] = new Sabre_VObject_Parameter('ENCODING', 'b');
+                                       $property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType());
+                                       $card->__set('PHOTO', $property);
                                } else {
-                                       if(file_exists($tmpfname)) {
-                                               unlink($tmpfname);
-                                       }
-                                       bailOut('Error saving temporary image');
+                                       OCP\Util::writeLog('contacts','savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG);
+                                       $card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType()));
+                               }
+                               $now = new DateTime;
+                               $card->setString('REV', $now->format(DateTime::W3C));
+                               if(!OC_Contacts_VCard::edit($id,$card)) {
+                                       bailOut(OC_Contacts_App::$l10n->t('Error saving contact.'));
                                }
+                               $tmpl = new OCP\Template("contacts", "part.contactphoto");
+                               $tmpl->assign('id', $id);
+                               $tmpl->assign('refresh', true);
+                               $tmpl->assign('width', $image->width());
+                               $tmpl->assign('height', $image->height());
+                               $page = $tmpl->fetchPage();
+                               OCP\JSON::success(array('data' => array('page'=>$page)));
                        } else {
-                               bailOut('Error resizing image');
+                               bailOut(OC_Contacts_App::$l10n->t('Error resizing image'));
                        }
                } else {
-                       bailOut('Error cropping image');
+                       bailOut(OC_Contacts_App::$l10n->t('Error cropping image'));
                }
        } else {
-               bailOut('Error creating temporary image');
+               bailOut(OC_Contacts_App::$l10n->t('Error creating temporary image'));
        }
 } else {
-       bailOut('Error finding image: '.$tmp_path);
-}
-
-if($tmp_path != '' && file_exists($tmp_path)) {
-       unlink($tmp_path);
+       bailOut(OC_Contacts_App::$l10n->t('Error finding image: ').$tmpkey);
 }
 
-?>
+OC_Cache::remove($tmpkey);
index dca8ede6d601d4ee70ea0247930fcc9e83dd1231..09c4e55d4a91a3373598b14176a6c61e04527bb4 100644 (file)
  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
-// Init owncloud
 
 // Check if we are a user
-// Firefox and Konqueror tries to download application/json for me.  --Arthur
-OCP\JSON::setContentTypeHeader('text/plain');
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
+// Firefox and Konqueror tries to download application/json for me.  --Arthur
+OCP\JSON::setContentTypeHeader('text/plain');
 function bailOut($msg) {
        OCP\JSON::error(array('data' => array('message' => $msg)));
        OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG);
@@ -39,46 +37,40 @@ function debug($msg) {
 // If it is a Drag'n'Drop transfer it's handled here.
 $fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false);
 if ($fn) {
-       // AJAX call
        if (!isset($_GET['id'])) {
-               OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No contact ID was submitted.', OCP\Util::DEBUG);
-               OCP\JSON::error(array('data' => array( 'message' => 'No contact ID was submitted.' )));
-               exit();
+               bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
        }
        $id = $_GET['id'];
-       $tmpfname = tempnam(get_temp_dir(), 'occOrig');
-       file_put_contents($tmpfname, file_get_contents('php://input'));
-       debug($tmpfname.' uploaded');
+       $tmpkey = 'contact-photo-'.md5($fn);
+       $data = file_get_contents('php://input');
        $image = new OC_Image();
-       if($image->loadFromFile($tmpfname)) {
+       sleep(1); // Apparently it needs time to load the data.
+       if($image->loadFromData($data)) {
                if($image->width() > 400 || $image->height() > 400) {
                        $image->resize(400); // Prettier resizing than with browser and saves bandwidth.
                }
                if(!$image->fixOrientation()) { // No fatal error so we don't bail out.
-                       debug('Couldn\'t save correct image orientation: '.$tmpfname);
+                       debug('Couldn\'t save correct image orientation: '.$tmpkey);
                }
-               if($image->save($tmpfname)) {
-                       OCP\JSON::success(array('data' => array('mime'=>$_SERVER['CONTENT_TYPE'], 'name'=>$fn, 'id'=>$id, 'tmp'=>$tmpfname)));
+               if(OC_Cache::set($tmpkey, $image->data(), 600)) {
+                       OCP\JSON::success(array('data' => array('mime'=>$_SERVER['CONTENT_TYPE'], 'name'=>$fn, 'id'=>$id, 'tmp'=>$tmpkey)));
                        exit();
                } else {
-                       bailOut('Couldn\'t save temporary image: '.$tmpfname);
+                       bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey);
                }
        } else {
-               bailOut('Couldn\'t load temporary image: '.$file['tmp_name']);
+               bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$tmpkey.$data);
        }
 }
 
-
+// Uploads from file dialog are handled here.
 if (!isset($_POST['id'])) {
-       OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No contact ID was submitted.', OCP\Util::DEBUG);
-       OCP\JSON::error(array('data' => array( 'message' => 'No contact ID was submitted.' )));
-       exit();
+       bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
 }
 if (!isset($_FILES['imagefile'])) {
-       OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OCP\Util::DEBUG);
-       OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' )));
-       exit();
+       bailOut(OC_Contacts_App::$l10n->t('No file was uploaded. Unknown error'));
 }
+
 $error = $_FILES['imagefile']['error'];
 if($error !== UPLOAD_ERR_OK) {
        $errors = array(
@@ -93,27 +85,26 @@ if($error !== UPLOAD_ERR_OK) {
 }
 $file=$_FILES['imagefile'];
 
-$tmpfname = tempnam(get_temp_dir(), "occOrig");
 if(file_exists($file['tmp_name'])) {
+       $tmpkey = 'contact-photo-'.md5(basename($file['tmp_name']));
        $image = new OC_Image();
        if($image->loadFromFile($file['tmp_name'])) {
                if($image->width() > 400 || $image->height() > 400) {
                        $image->resize(400); // Prettier resizing than with browser and saves bandwidth.
                }
                if(!$image->fixOrientation()) { // No fatal error so we don't bail out.
-                       debug('Couldn\'t save correct image orientation: '.$tmpfname);
+                       debug('Couldn\'t save correct image orientation: '.$tmpkey);
                }
-               if($image->save($tmpfname)) {
-                       OCP\JSON::success(array('data' => array('mime'=>$file['type'],'size'=>$file['size'],'name'=>$file['name'], 'id'=>$_POST['id'], 'tmp'=>$tmpfname)));
+               if(OC_Cache::set($tmpkey, $image->data(), 600)) {
+                       OCP\JSON::success(array('data' => array('mime'=>$file['type'],'size'=>$file['size'],'name'=>$file['name'], 'id'=>$_POST['id'], 'tmp'=>$tmpkey)));
                        exit();
                } else {
-                       bailOut('Couldn\'t save temporary image: '.$tmpfname);
+                       bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey);
                }
        } else {
-               bailOut('Couldn\'t load temporary image: '.$file['tmp_name']);
+               bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']);
        }
 } else {
        bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?');
 }
-
 ?>
diff --git a/apps/contacts/dynphoto.php b/apps/contacts/dynphoto.php
deleted file mode 100644 (file)
index ea6cef2..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * ownCloud - Image generator for contacts.
- *
- * @author Thomas Tanghus
- * @copyright 2012 Thomas Tanghus <thomas@tanghus.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-// Init owncloud
-
-$tmp_path = $_GET['tmp_path'];
-$maxsize = isset($_GET['maxsize']) ? $_GET['maxsize'] : -1;
-header("Cache-Control: no-cache, no-store, must-revalidate");
-
-OCP\Util::writeLog('contacts','dynphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
-
-$image = new OC_Image($tmp_path);
-if($maxsize != -1) {
-       $image->resize($maxsize);
-}
-$image();
index df3b59c349a5c8ec71fc0cca61a7ffc335d3f175..8b9a80c95200af255a90e8665af3b95d5edd321b 100644 (file)
@@ -1162,9 +1162,9 @@ Contacts={
                                        }
                                });
                        },
-                       editPhoto:function(id, tmp_path){
-                               //alert('editPhoto: ' + tmp_path);
-                               $.getJSON(OC.filePath('contacts', 'ajax', 'cropphoto.php'),{'tmp_path':tmp_path,'id':this.id},function(jsondata){
+                       editPhoto:function(id, tmpkey){
+                               //alert('editPhoto: ' + tmpkey);
+                               $.getJSON(OC.filePath('contacts', 'ajax', 'cropphoto.php'),{'tmpkey':tmpkey,'id':this.id},function(jsondata){
                                        if(jsondata.status == 'success'){
                                                //alert(jsondata.data.page);
                                                $('#edit_photo_dialog_img').html(jsondata.data.page);
@@ -1194,6 +1194,7 @@ Contacts={
                                                Contacts.UI.Card.loadPhotoHandlers();
                                        }else{
                                                OC.dialogs.alert(response.data.message, t('contacts', 'Error'));
+                                               wrapper.removeClass('wait');
                                        }
                                });
                                Contacts.UI.Contacts.refreshThumbnail(this.id);
index 599951d9a972fb8096dfc083c99488414c635183..d7f0efc57d7c1d962592b5443f39c3884016275b 100644 (file)
@@ -1,7 +1,7 @@
 <?php 
 $id = $_['id'];
-$tmp_path = $_['tmp_path'];
-OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
+$tmpkey = $_['tmpkey'];
+OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmpkey: '.$tmpkey, OCP\Util::DEBUG);
 ?>
 <script language="Javascript">
        jQuery(function($) {
@@ -38,7 +38,8 @@ OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_pa
                return true;
        });*/
 </script>
-<img id="cropbox" src="<?php echo OCP\Util::linkToAbsolute('contacts', 'dynphoto.php'); ?>?tmp_path=<?php echo urlencode($tmp_path); ?>" />
+<?php if(OC_Cache::hasKey($tmpkey)) { ?>
+<img id="cropbox" src="<?php echo OCP\Util::linkToAbsolute('contacts', 'tmpphoto.php'); ?>?tmpkey=<?php echo $tmpkey; ?>" />
 <form id="cropform"
        class="coords"
        method="post"
@@ -47,7 +48,7 @@ OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_pa
        action="<?php echo OCP\Util::linkToAbsolute('contacts', 'ajax/savecrop.php'); ?>">
 
        <input type="hidden" id="id" name="id" value="<?php echo $id; ?>" />
-       <input type="hidden" id="tmp_path" name="tmp_path" value="<?php echo $tmp_path; ?>" />
+       <input type="hidden" id="tmpkey" name="tmpkey" value="<?php echo $tmpkey; ?>" />
        <fieldset id="coords">
        <input type="hidden" id="x1" name="x1" value="" />
        <input type="hidden" id="y1" name="y1" value="" />
@@ -58,5 +59,8 @@ OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_pa
        </fieldset>
        <iframe name="crop_target" id='crop_target' src=""></iframe>
 </form>
-
-
+<?php
+} else { 
+       echo $l->t('The temporary image has been removed from cache.');
+}
+?>
diff --git a/apps/contacts/tmpphoto.php b/apps/contacts/tmpphoto.php
new file mode 100644 (file)
index 0000000..5fde8de
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/**
+ * ownCloud - Image generator for contacts.
+ *
+ * @author Thomas Tanghus
+ * @copyright 2012 Thomas Tanghus <thomas@tanghus.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+$tmpkey = $_GET['tmpkey'];
+$maxsize = isset($_GET['maxsize']) ? $_GET['maxsize'] : -1;
+header("Cache-Control: no-cache, no-store, must-revalidate");
+
+OCP\Util::writeLog('contacts','tmpphoto.php: tmpkey: '.$tmpkey, OCP\Util::DEBUG);
+
+$image = new OC_Image();
+$image->loadFromData(OC_Cache::get($tmpkey));
+if($maxsize != -1) {
+       $image->resize($maxsize);
+}
+$image();