可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Is there a resource that lists ALL the mimeTypes in existence?
I have found a few places with under 1000 mimeTypes, but then they still don't include common ones like .rar, .fla, .rb, .docx!
Does anyone have a COMPLETE list of mimetypes? Not down to the most obsure "company-only" ones, but at least all of the ones we might use.
Also, I'm looking for a list that maps file extensions to mimeTypes.
回答1:
http://www.iana.org/assignments/media-types/ lists the "official" mime-types, but it doesn't prevent anyone making their own an not registering it with IANA.
回答2:
Here's the most up-to-date mime.types maintained by the Apache HTTPD community:
http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/conf/mime.types?view=annotate
回答3:
IANA lists the official ones. A list which includes file extensions which I find useful is the one included as /etc/mime.types
in Debian & Ubuntu.
The Apache web server project also maintains a list.
回答4:
I collected MIME types and file extensions from many sites and lists, and here's the result: https://s-randomfiles.s3.amazonaws.com/mime/allMimeTypes.txt
I also created a JSON file: https://s-randomfiles.s3.amazonaws.com/mime/allMimeTypes.json
Please tell me if something is missing or incorrect
回答5:
iana is tracking the official ones but of course folks can always declare their own...
In other words, it is doubtful you'll ever get the full list on the Planet.
Also consider the case of NPAPI plugins which declare MIME-types just to be be easily accessible... and these MIME-types might be not interesting to you for a reason or another.
回答6:
If your are using Java you could use Apache Tika, which is a powerful library for dealing with file types. With it you can easily get the preferred extension related to a mime type with a couple of rows:
TikaConfig config = TikaConfig.getDefaultConfig();
MimeType mimeType = config.getMimeRepository().forName("image/png"); //Generally your textual mime type
String extension = mimeType.getExtension();
// this would return the extension with the dot. For "image/png" returns ".png"
In this way you don't have to mess with downloading and parsing a file with the associations, I find it very comfortable. This is the way I've done the trick.
回答7:
There is a good Mime Type Table you can find on https://drive.google.com/open?id=0By00BwrZ8886VUg3ak9faG5mTU0
Which is updated 27-02-2017.
I am sure that meet your all needful mime type.
回答8:
There's a good table in the classic book "HTTP: The Definitive Guide" by Gourley and Totty (O'Reilly, with a squirrel on the cover) in Appendix D. It appears to be complete and up-to-date as of the time the book was written (in 2002). That was a long time ago, but you'll find all the old favorites there as well as obscure "company-only" ones.
ISBN 1-56592-509-2, http://oreilly.com/catalog/9781565925090/
回答9:
Here is a full list that is easy on the eyes:
http://www.webmaster-toolkit.com/mime-types.shtml
回答10:
This site list some more such as '.docx'
http://www.freeformatter.com/mime-types-list.html#mime-types-list
回答11:
User Paul Tarjan said in a comment:
There is a pretty good list on stdicon.com : stdicon.com/mimetypes
This website is no longer available, but the most recent archive is https://web.archive.org/web/20161015175648/http://www.stdicon.com/mimetypes
Note that this site doesn't mention "application/x-zip-compressed" (and it's not because of the escaping of slashes either) so it's not perfect.
回答12:
I took the list from Apache mime.types as of Fri Sep 29 15:10:29 2017 UTC and wrote a script to convert it to a json mapping. The json is too big for stackoverflow answer. You can find it here mimes.json.
script to generate the mapping:
# mime_to_json.py
# get the mime.types from
# http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=markup
import sys
import re
import json
mapping = {}
with open(sys.argv[1], "r") as handle:
for line in handle:
line = line.strip()
if line[0] == "#":
continue
parts = re.split("\s+", line)
mime = parts[0]
del parts[0]
for ext in parts:
mapping[ext] = mime
print(json.dumps(mapping, indent=4, sort_keys=True))
回答13:
My list (about 680 types) mimetype in xml here