Detecting MIME type of a shared file
Tomeu Vizoso
tomeu at tomeuvizoso.net
Wed Mar 19 18:24:13 EDT 2008
On Wed, Mar 19, 2008 at 11:08 PM, James Simmons
<jim.simmons at walgreens.com> wrote:
>
> Tomeu and Michael,
>
> It turns out Python has a method you can pass a filename to and it will
> identify if the file is a Zip file or not, based on the "magic number", not
> the filename. It seems to do the trick.
As a rule of thumb, I would first try to get a mime-type I can trust,
and only if I cannot (I get for example application/octet-stream), I
would try to sniff the type.
But in your case you may be right by just sniffing it.
Tomeu
More information about the Devel
mailing list