0

I'm doing a computing assignment, and I read this passage and had no clue. I don't get the full picture behind what MIME-type are...

"Note that filelename extensions are not the same as file types. Some filesles may end in .html or .htm but the header indicates that the MIME-type is text/plain. On the other hand, a file may have an extension .txt - or no extension - but have a MIME-type of text/html. The MIME-type defines the true type of the file."

What do you mean by the MIME-type defines the true type of file?

Thank you so much!

  • 1
    Does this answer your question? [What is a MIME type?](https://stackoverflow.com/questions/3828352/what-is-a-mime-type) – Lescurel Mar 31 '20 at 08:18

3 Answers3

0

I can give a self-learning experience

in windows open Registry Editor

Start -> Run -> regedit

Expand HKEY_CLASSES_ROOT

choose any extension you want say (.pdf)

you can understand how is it related and how it is treated

Again expand .pdf, you can see through which application it is usually processed

this makes a perfect learning experience of various MIME types and its content type and which application it is as default processed

Dickens A S
  • 3,824
  • 2
  • 22
  • 45
0

MIME type is not only determined by the ending of a file, it also refers to the content in the file i.e. a python script s.py has MIME type text/x-python, while an empty file named s.py has inode/x-empty on a linux system

In linux use file --mime-type FILE_NAME command

How can I find out a file's MIME type (Content-Type)?

ralf htp
  • 9,149
  • 4
  • 22
  • 34
0

MIME types are just a way to identify the type of a file. Typically, there are two ways to figure out what the type of a file is:

  1. Look at the file extension. For example, a pdf is usually saved as file.pdf ending with the extension pdf. This is a hint that the type of the file is pdf file. However, you can change the name of the file and simply change its extension to something else. So, the name of a file does not necessarily have to indicate its type

  2. Look at the contents of the file and try to guess based on how its arranged in binary.

Most binary files have very specific representation inside a file. For example, if you open a pdf file in a notepad (or any text editing program), you will find that it starts with %PDF-. Followed by some numbers and potentially weird characters. This tells you that this is a pdf type.

Why is this useful? Files are simply saved as blocks of binary data. However, certain files can only be opened by certain programs (for example, music files can't be "opened" by text editors, it can only be played with a music player). By figuring out the MIME type of a file, you can understand how to interpret the data in the file (for example, text, image, video, audio are common mime types). Then, you can use the correct software to use the file.