[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Determine mime type of a file
- From: steve donovan <steve.j.donovan@...>
- Date: Mon, 2 May 2011 11:43:25 +0200
On Mon, May 2, 2011 at 11:32 AM, Marco <firstname.lastname@example.org> wrote:
> What do you mean by catalog? A file extension - mime type
That is exactly what the Gnome MIME XML files provide.
>That would quickly break when a file has no
> extension (file -i is not confused by this).
Well, if we can't find it, then we have to give some default, like
text/plain or application/binary. 'file' is a very clever command ;)
A portable solution would start with a list of the common registered
MIME types, and encode it as a Lua table. You would probably find
such tables in a number of Lua web frameworks, but making such a table
should be straightforward, either lots of typing or an opportunity to
write a fun script ;)