simplemagic icon indicating copy to clipboard operation
simplemagic copied to clipboard

.xls file shows null in return of getMimeType

Open keivanshir opened this issue 3 years ago • 0 comments

Hi @j256 told me to put this issue here. I use this code to get the Mime Type of the excel file but it shows null in mimeType of ContentInfo. I can get the file format from message and name properties but I really need the mimeType and extension. I've attached the file so you can test it too.

try {
   ContentInfoUtil util = new ContentInfoUtil();
   InputStream stream = new FileInputStream(file);
   ContentInfo info = util.findMatch(stream);
   
   if (info != null) {
       String mimeType1 = info.getMimeType();
   }
} catch (Exception e){
   e.printStackTrace();
}

1.xls

keivanshir avatar Aug 02 '22 05:08 keivanshir