private bool CheckIfImageFile(IFormFile file) { byte[] fileBytes; using (var ms = new MemoryStream()) { file.CopyTo(ms); fileBytes = ms.ToArray(); } return(WriteHelper.GetImageFormat(fileBytes) != WriteHelper.ImageFormat.unknown); }
// ensure that the file is an image private bool CheckIfImageFile(IFormFile file) { byte[] fileBytes; using (var ms = new MemoryStream()) { file?.CopyTo(ms); fileBytes = ms.ToArray(); } // Convert byte[] to Base64 String //string base64String = Convert.ToBase64String(fileBytes); return(WriteHelper.GetImageFormat(fileBytes) != WriteHelper.ImageFormat.unknown); }