[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using mimetype and file to guess content-type
From: |
Jean Louis |
Subject: |
Re: Using mimetype and file to guess content-type |
Date: |
Tue, 8 Jun 2021 10:44:56 +0300 |
User-agent: |
Mutt/2.0.7+183 (3d24855) (2021-05-28) |
* Sergey Poznyakoff <gray@gnu.org.ua> [2021-06-08 08:14]:
> Jean Louis <bugs@gnu.support> ha escrit:
>
> > In order to guess the content-type, I am using these functions. It
> > appears that Perl's `mimetype' works so much better than `file', for
> > example it will give tell for .gpg file that it is pgp encrypted, but
> > `file' will tell it is application octet stream.
>
> That depends only on the set of "magic" files your installation of
> "file" is using (/etc/file/magic).
$ file --mime-type test.gpg
test.gpg: application/octet-stream
~
$ mimetype -i test.gpg
test.gpg: application/pgp-encrypted
in this case Perl's tool gives better result. I did not research all
command line parameters.
Best would be to avoid any of external tools.
> > Overall I am replacing some `mutt' based functions with `mail' and
> > that works well so far. But `mutt' on the command line in batch mode
> > does recognize the attached file's content type while `mail' does not.
> >
> > I understand that `mail' is asking for the content-type to be provided
> > by user, though question is if some mechanism exists in C libraries
> > that the content-type gets automatically recognized if not supplied on
> > the command line?
>
> Yes, mailutils provides mailcap functions designed expressly for that
> purpose. It would be nice to modify mail to use them.
Do you think recognition would be "pretty" accurate?
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/