コード例 #1
0
 /// <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);
 }
コード例 #2
0
 /// <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());
 }