I am using apache tika for detecting the mime type of audio and video files. For some reason tika reports the mime type of the wma file (Windows Media Audio format owned by Microsoft) as application/octet-stream. Do you know a better way to find mime type of file in java? Or can I use tika itself to query this information?
finding mime type of wma files using java
2.2k views Asked by Ajith Jose At
2
There are 2 answers
1

Tika should be able to detect the files if you supply a filename for them, eg
Metadata m = new Metadata();
m.add(Metadata.RESOURCE_NAME_KEY, filename);
detector.detect(stream, m);
I've opened https://issues.apache.org/jira/browse/TIKA-629 to track the lack of mime magic detection for if you don't have the filename to hand.
As per Microsoft support: http://support.microsoft.com/kb/284094, the mime type of WMA should be
audio/x-ms-wma
. As per: http://kb.iu.edu/data/agtj.html the mime-typeapplication/octet-stream
represents a binary file. I am not sure why TIKA is failing to recognize the proper mime type but it is the fallback/backup strategy to returnapplication/octet-stream
if the actual mime is not recognizable. The reason for failure could be many:Have a look at the below links for finding out mime-types in Java: