GateKiller
GateKiller

Reputation: 75869

File Extension to MIME Type Web Service?

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

Upvotes: 11

Views: 7182

Answers (8)

Paul Tarjan
Paul Tarjan

Reputation: 50612

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.

Upvotes: 18

Amandasaurus
Amandasaurus

Reputation: 60709

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.

Upvotes: 1

Tamas Czinege
Tamas Czinege

Reputation: 121324

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.

Upvotes: 0

Davy Landman
Davy Landman

Reputation: 15439

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.

Upvotes: 1

Xn0vv3r
Xn0vv3r

Reputation: 18184

The only thing I could imagine would be parsing the list which comes with the apache server mime.types. The list is maintained by The Apache Software Foundation and depends on www.iana.org

Upvotes: 9

Anton Gogolev
Anton Gogolev

Reputation: 115749

The only thing that comes to mind is to parse output from http://www.file-extensions.org/

Upvotes: 0

Fabian Steeg
Fabian Steeg

Reputation: 45734

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.

Upvotes: 5

boutta
boutta

Reputation: 24619

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.

Upvotes: 1

Related Questions