2

There are two calsses in Apache Tika (as of 1.4): org.apache.tika.mime.MimeType and org.apache.tika.mime.MediaType. They both represent something similar, and seems to solve similar tasks. I wonder, whaat is the purpose of these classes and in which cases should I use what?

I'm implementing mime-type and file extension checks for loading images at the moment.

WeGa
  • 801
  • 4
  • 10
  • 24
  • https://stackoverflow.com/questions/9258108/whats-the-difference-between-mediatype-contenttype-and-mimetype – Lukas Bradley Dec 15 '17 at 14:01
  • 1
    @LukasBradley, the question is not about the difference between the definitions of these words, but about how to use these Tika's classes properly while parsing and checking media types – WeGa Dec 15 '17 at 15:17
  • 1
    Understood, and apologies for being brief. I got pulled away and just pasted the link quickly. In short, the two classes are just that: a delination of the two "different" types as discussed in that link. Honestly, they are the same damn thing. MIME was originally for email attachment types, and they were defined before the web existed. One the Internet got bigger, and media was everywhere, the Media Type was created to do basically the same thing. – Lukas Bradley Dec 15 '17 at 18:47

1 Answers1

1

From what I can find, it appears that Media Type is going to be the new terminology for MIME Type in the future.

This according to this page https://www.iana.org/assignments/media-types/media-types.xhtml which says, "[RFC2046] specifies that Media Types (formerly known as MIME types) and Media Subtypes will be assigned and listed by the IANA."

So it appears that they are, for the most part, one in the same. As for how Tika implements them, I'd suggest going over the documentation. Here are links to the pages for MediaType and MimeType from Apache Tika 1.17:

From personal experience, the Tika MimeType is very trustworthy for file extension verification, so I'd say to keep using that for now, but keep an eye out from Apache to make sure it doesn't get deprecated/become obsolete as MediaType becomes the main terminology.

Community
  • 1
  • 1
Francis Bartkowiak
  • 1,374
  • 2
  • 11
  • 28
  • Agreed, MimeType has richer api and a link to MediType - getType(). Thus, I think I'll use MimeType, even though it's considered to become obsolete in the future – WeGa Dec 18 '17 at 06:50