File Extension to MIME Type Web Service?

2019-03-10 03:01发布

Are there any web services which will allow me to provide a file extension and it would return a list of possible MIME types?

For example:

http://mimetype.com/getMime/doc

Which could return:

application/msword,application/docappl/text,application/vnd.msword,application/vnd.ms-word,application/winword,application/word,application/x-msw6,application/x-msword

I don't want to use Urlmon.dll and I would prefer not having to keep my own list up-to-date.

Thanks

8条回答
Melony?
2楼-- · 2019-03-10 03:27

This webservice could be very simple, a small DB / in memory store which could be as simple as a Dictionary<String, String> and just do a key lookup and return the result.

The first dataset could be (for example) based on http://www.webmaster-toolkit.com/mime-types.shtml.

The problem would probably be the hosting of such a webservice.

查看更多
唯我独甜
3楼-- · 2019-03-10 03:31

It won't give you the MIME type, but the good olde' Microsoft File Association Web Service could still help you. You access it this way:

http://shell.windows.com/fileassoc/0409/xml/redir.asp?Ext=xls

where 0409 means English (US) and xls is the file extension. On the plus side, it will be there and constantly updated... well, until Microsoft decides to pull the plug. Which can happen any time.

查看更多
迷人小祖宗
4楼-- · 2019-03-10 03:35

Though its not exactly what you are asking for, this information is available via search by format in the PRONOM registry. The result is more fine-grained than MIME types, but you can get MIME info if available for the results (e.g. here, in the 'identifiers' section). There is also the DROID tool available to access this information via GUI, Java API or command line interface.

查看更多
乱世女痞
5楼-- · 2019-03-10 03:36

Sorry that I don't have a webservice for the task on hand, but you could use the fileext page and maybe parse the response if you can query the extension programmatically. Maybe a first step in the right direction.

查看更多
Ridiculous、
6楼-- · 2019-03-10 03:42

I don't know if there is a web service that would do this, but the libmagic library (http://en.wikipedia.org/wiki/Libmagic) is used for identifying filetypes and might be helpful for you.

查看更多
做自己的国王
7楼-- · 2019-03-10 03:48

I just created this as part of my mimetype <-> icon service

http://stdicon.com/

For example :

http://stdicon.com/ext/html

It runs on appengine so it should have high availability.

查看更多
登录 后发表回答