Esempio n. 1
0
        public async Task <string> UploadAvatar(IFormFile file, bool isPreview)
        {
            if (file != null && file.Length <= 3 * 1024 * 1024 && file.ContentType.Contains("image"))
            {
                using (var memoryStream = new MemoryStream())
                {
                    await file.CopyToAsync(memoryStream);

                    byte[] image = memoryStream.ToArray();

                    return(await _personalDataService.AddAvatarAsync(_userManager.GetCurrentUserId(), isPreview, image));
                }
            }

            return(null);
        }