I have a SOAP-WebService providing a method where the caller is able to upload a PDF, JPG, PNG or BMP file. For correct processing I need to get the MIME-Type out of the DataHandler. I tried to get the MIME-Type with Apache Tika:
Tika tika = new Tika();
InputStream stream = dataHandler.getInputStream();
String mimeType = tika.detect(stream);
Now my problem:
Most times Tika detects the correct MIME-Types but in a few cases of uploading JPGs it detects plain/text
instead of image/jpeg
. How can I solve this?
Thank you in advance!