/// <summary> /// Method to check if file is image file /// </summary> /// <param name="file"></param> /// <returns></returns> private bool CheckIfImageFile(IFormFile file) { var ms = new MemoryStream(); file.CopyTo(ms); return(WriterHelper.GetImageFormat(ms) != WriterHelper.ImageFormat.unknown); }
private bool IsImageValid(IFormFile image) { byte[] fileBytes; using (var ms = new MemoryStream()) { image.CopyTo(ms); fileBytes = ms.ToArray(); } return(WriterHelper.GetImageFormat(fileBytes) != WriterHelper.ImageFormat.unknown); }
private bool CheckIfImageFile(IFormFile file) { byte[] fileBytes; using (var ms = new MemoryStream()) { file.CopyTo(ms); fileBytes = ms.ToArray(); } return(WriterHelper.GetImageFormat(fileBytes) != WriterHelper.ImageFormat.unknown); }
/// <summary> /// Method to check if file is image file /// </summary> /// <param name="file"></param> /// <returns></returns> public bool CheckIfImageFile(IFormFile file) { if (file != null) { byte[] fileBytes; using (MemoryStream ms = new MemoryStream()) { file.CopyTo(ms); fileBytes = ms.ToArray(); } return(WriterHelper.GetImageFormat(fileBytes) != WriterHelper.ImageFormat.unknown); } return(false); }