0

I retrieve the content of a file via HTTP-request and let Tika guess which MIME type it is most likely, e.g.

byte[] myFileContent;
.....
String mime_type=new Tika().detect(myFileContent);

Then I store the content in the File system and calculate the M5-sum as unique file name (only several hundereds of files). Most likely the content is PDF.

String extension=".pdf";
File write=new File(MD5 + extension);
if (write.exists()) {....
  ....
}

Matter of fact is that I want to set the content more or less dynamically. Is there some way to retrieve the list automatically? Instead of using a handmade list for checking? Something like

extension=Tika.suggestFileExtension(myFileContent);
LeO
  • 4,238
  • 4
  • 48
  • 88
  • 1
    Wouldn't the MIME-type be in the HTTP response? – maksimov Mar 09 '17 at 10:57
  • Not really - I mean it would be great but the data is encapsulated in JSON - therefore the type remains as text. But the hint is nice and I like it :-) – LeO Mar 09 '17 at 11:20

0 Answers0