Created
September 25, 2020 14:24
-
-
Save bjornmicallef/b53a9670811f50968642ebf379548d35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ImageService : IImageService | |
{ | |
public async Task<string> SaveImage(int userId, IFormFile uploadedImage) | |
{ | |
// convert IFormFile to Image and validate | |
using (var image = Image.FromStream(uploadedImage.OpenReadStream())) | |
{ | |
if (image.Width > 640 || image.Height > 480) | |
{ | |
// do some resizing and then save image | |
} | |
else | |
{ | |
// save original image for user | |
} | |
} | |
return "image saved"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment