/// <summary> /// Checks if file is an image /// </summary> public bool IsImageFileType(IFormFile file) { byte[] fileBytes; using (var ms = new MemoryStream()) { file.CopyTo(ms); fileBytes = ms.ToArray(); } return(WriterHelper.GetImageFormat(fileBytes) != WriterHelper.ImageFormat.unknown); }
/// <summary> /// Gets the file extension of a file /// </summary> public string GetFileExtension(IFormFile file) { byte[] fileBytes; using (var ms = new MemoryStream()) { file.CopyTo(ms); fileBytes = ms.ToArray(); } return(WriterHelper.GetImageFormat(fileBytes).ToString()); }