Search code examples
javaandroidmime

What is MIME-type data?


I was reading article about intents and i have encountered word MIME.
In android-documentation I couldn't find clear explanation about what is mime-type.
From documentation:

type -- Specifies an explicit type (a MIME type) of the intent data. Normally the type is inferred from the data itself. By setting this attribute, you disable that evaluation and force an explicit type.

1) What exactly is MIME
2) Why exactly do we need them ?
3) How can it be inferred from Uri ?

P.S. Do not link me to documentation, I have read it. Thanks.


Solution

  • MIME stands for Multipurpose Internet Mail Extensions. Is used to determine file type (basically extension) in internet communication.

    We need them as a metadata for example for browser to convert bytes received from server to proper file extension. Here is list like for example image/gif convert received data to .gif extension

    You can extract mime type from request/response header. Content-type Content-Type: image/gif. You can also request some specific mime type by Accept http request attribute where you specify requested mime type. If server fails to convert your data to requested mime type it will respond with 406 Not Acceptable error code.