Added log info for save pic
Change-Id: I5909345ef8eee14a30aae8b85ac3f28130e1d409 Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
91acb2bfc4
commit
eaaee95a76
|
@ -41,6 +41,7 @@ final class PrivateUserSerializer extends BaseUserSerializer
|
|||
protected static $array_mappings = [
|
||||
'Email' => 'email:json_string',
|
||||
'Bio' => 'bio:json_string',
|
||||
'Company' => 'company:json_string',
|
||||
'Gender' => 'gender:json_string',
|
||||
'SpamType' => 'spam_type:json_string',
|
||||
'Identifier' => 'identifier:json_string',
|
||||
|
|
|
@ -317,6 +317,7 @@ final class UserService extends AbstractService implements IUserService
|
|||
public function updateProfilePhoto($user_id, UploadedFile $file, $max_file_size = 10485760): User
|
||||
{
|
||||
$user = $this->tx_service->transaction(function() use($user_id, $file, $max_file_size) {
|
||||
|
||||
$allowed_extensions = ['png', 'jpg', 'jpeg'];
|
||||
|
||||
$user = $this->repository->getById($user_id);
|
||||
|
@ -325,6 +326,8 @@ final class UserService extends AbstractService implements IUserService
|
|||
$fileName = $file->getClientOriginalName();
|
||||
$fileExt = $file->extension() ?? pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
|
||||
Log::debug(sprintf("UserService::updateProfilePhoto user %s fileName %s fileExt %s", $user_id, $fileName, $fileExt));
|
||||
|
||||
if (!in_array($fileExt, $allowed_extensions)) {
|
||||
throw new ValidationException(sprintf( "file does not has a valid extension (%s).", join(",", $allowed_extensions)));
|
||||
}
|
||||
|
@ -336,6 +339,7 @@ final class UserService extends AbstractService implements IUserService
|
|||
$fileName = FileNameSanitizer::sanitize($fileName);
|
||||
$path = User::getProfilePicFolder();
|
||||
|
||||
Log::debug(sprintf("UserService::updateProfilePhoto user %s saving file to swift path %s fileName %s", $user_id, $path, $fileName));
|
||||
Storage::disk('swift')->putFileAs($path, $file, $fileName);
|
||||
|
||||
$user->setPic($fileName);
|
||||
|
|
Loading…
Reference in New Issue