public async Task <ActionResult> UploadAvatar([FromBody] ImageUploadBindModel model) { byte[] file = Misc.GetImageFromBase64(model.imageBase64); string containerName = "profilepictures"; if (file.Length > 0) { string fileName = Misc.GetRandomFileName(model.fileName); Uri fileUri = await _fileService.UploadImage(containerName, file, fileName); if (fileUri != null) { _profileService.AddProfilePicture(UserId, fileUri.ToString()); string sasUri = _fileService.GetSasUri(containerName, fileUri.ToString()); return(Ok(new { avatarUrl = sasUri })); } else { return(Ok("upload failed")); } } else { return(Ok("NoFileSelected")); } }