summaryrefslogtreecommitdiff
path: root/app/Model/AvatarFile.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model/AvatarFile.php')
-rw-r--r--app/Model/AvatarFile.php32
1 files changed, 27 insertions, 5 deletions
diff --git a/app/Model/AvatarFile.php b/app/Model/AvatarFile.php
index 36784e60..9f47ccc7 100644
--- a/app/Model/AvatarFile.php
+++ b/app/Model/AvatarFile.php
@@ -75,20 +75,20 @@ class AvatarFile extends Base
}
/**
- * Upload avatar image
+ * Upload avatar image file
*
* @access public
* @param integer $user_id
* @param array $file
* @return boolean
*/
- public function uploadFile($user_id, array $file)
+ public function uploadImageFile($user_id, array $file)
{
try {
if ($file['error'] == UPLOAD_ERR_OK && $file['size'] > 0) {
- $destination_filename = $this->generatePath($user_id, $file['name']);
- $this->objectStorage->moveUploadedFile($file['tmp_name'], $destination_filename);
- $this->create($user_id, $destination_filename);
+ $destinationFilename = $this->generatePath($user_id, $file['name']);
+ $this->objectStorage->moveUploadedFile($file['tmp_name'], $destinationFilename);
+ $this->create($user_id, $destinationFilename);
} else {
throw new Exception('File not uploaded: '.var_export($file['error'], true));
}
@@ -102,6 +102,28 @@ class AvatarFile extends Base
}
/**
+ * Upload avatar image content
+ *
+ * @access public
+ * @param integer $user_id
+ * @param string $blob
+ * @return boolean
+ */
+ public function uploadImageContent($user_id, &$blob)
+ {
+ try {
+ $destinationFilename = $this->generatePath($user_id, 'imageContent');
+ $this->objectStorage->put($destinationFilename, $blob);
+ $this->create($user_id, $destinationFilename);
+ } catch (Exception $e) {
+ $this->logger->error($e->getMessage());
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
* Generate the path for a new filename
*
* @access public