Skip to content

Instantly share code, notes, and snippets.

@bjornmicallef
Created September 25, 2020 14:24
Show Gist options
  • Save bjornmicallef/b53a9670811f50968642ebf379548d35 to your computer and use it in GitHub Desktop.
Save bjornmicallef/b53a9670811f50968642ebf379548d35 to your computer and use it in GitHub Desktop.
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