Good practices regarding MIME type
John Cowan
cowan at ccil.org
Thu Dec 10 21:30:47 GMT 2020
libmagic uses the local mime-types file(s) but is conditionalized to know
where they are on different operating systems, so it's better to use it,
even if it is not installed by default.
On Thu, Dec 10, 2020 at 4:26 PM Omar Polo <op at omarpolo.com> wrote:
>
> Solène Rapenne <solene at perso.pw> writes:
>
> > Hi,
> >
> > I wrote a gemini server in C and I currently use an hardcoded list of
> > file extensions <-> MIME type assocation.
> > This isn't great because it relies on file extension which can be
> > wrong, but a file without extension would
> > use a default.
> >
> > I chose to set a default text/gemini in case the extension is unknown
> > or if the file has no extension.
> >
> > What are the good practices to determine a file MIME type?
> >
> > regards
> > Solène
>
> I'm using the same approach in my server, but there are two alternatives
> I know:
>
> - using /usr/share/misc/mime.types (still a list, but probably more
> complete than a manual one). Don't know if it's widespread, but
> it's present in base on OpenBSD :)
> - using libmagic: it's a library to detect the MIME type by reading the
> file. it powers the file(1) command on some unices. The drawback is
> that it needs to open and read the file, whereas guessing from the
> extension doesn't.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.orbitalfox.eu/archives/gemini/attachments/20201210/df9c7b33/attachment.htm>
More information about the Gemini
mailing list