public async Task<string> UploadPicture(UploadImageModel model) { var cloudinary = new Cloudinary(Account); cloudinary.Api.Secure = true; //reads the Image in the IFormFile into a bytes then we convert this to a base64 string byte[] bytes; using (var memoryStream = new MemoryStream()) { model.UploadImage.CopyTo(memoryStream); bytes = memoryStream.ToArray(); } string base64 = Convert.ToBase64String(bytes); var prefix = @"data:image/png;base64,"; var imagePath = prefix + base64; // create a new ImageUploadParams object and assign the directory name var uploadParams = new ImageUploadParams() { File = new FileDescription(imagePath), Folder = "EndSars/img" }; // pass the new ImageUploadParams object to the UploadAsync method of the Cloudinary Api var uploadResult = await cloudinary.UploadAsync(@uploadParams); // adds the new image to be uploaded to the database var image = new GalleryImage() { Title = model.Title, Created = DateTime.Now, Url = uploadResult.Url.AbsoluteUri, Tags = ParseTags(model.Tags) }; _ctx.Add(image); await _ctx.SaveChangesAsync(); return uploadResult.SecureUrl.AbsoluteUri; }