From 300dabe6b4e9e648c1111363fad8154def7cfb5f Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 7 May 2016 12:59:35 -0400 Subject: Added support for LDAP user photo profile --- app/Model/AvatarFile.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'app/Model/AvatarFile.php') 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)); } @@ -101,6 +101,28 @@ class AvatarFile extends Base return true; } + /** + * 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 * -- cgit v1.2.3