简体   繁体   中英

Getting mime type Description/Name/Friendly Format

Since I don't know how it is called the name of the Friendly format of the Mime Types like for example:

image/bmp - > Bitmap
image/x-icon - > Icon

I would like to ask how I can retrieve that information in some kind of Map with Key->Value (I am using Java)
Or some library where I can get them from.
I am using apache tika and there with MimeTypes.forName("application/pdf").getDescription(); is not returning me anything.
Anyways I think this question is irrelevant for every programming language.
I've found one website where I can see them but it is made with Table and I cannot extract them so I can receive them in key->value type HERE

You could just scrape that page.

If you're using Firefox with Firebug or Chrome then paste the following Javascript into an eval window and run it.

(The right hand side panel in Firebug's Console tab, or in Chrome; Tools > Developer Tools and paste in Console tab)

jQuery('#mime-types-list tbody tr').each(function(i, tr){
    var tds = jQuery(tr).children('td');
    console.log("map.put(\"" + jQuery(tds[1]).text() + "\", \"" + jQuery(tds[0]).text() + "\");");
});

This will generate 684 entries, to copy 'n' paste, such as:

map.put("text/turtle", "Turtle (Terse RDF Triple Language)");

Just convert the string inside console.log to suit your syntax/format needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM