[Zope-dev] Re: inconsistent mimetype assignment for uploaded files

Fred Drake fdrake at gmail.com
Tue Oct 5 10:42:50 EDT 2004


On Tue, 05 Oct 2004 12:44:32 +0200, Tino Wildenhain <tino at wildenhain.de> wrote:
> Well, the problem might be the asymptation part of the filename
> should be considered an indicator of its contents.

That is a nuissance.  It's unfortunate we still don't have any sort of
common type system for bytestreams that's supported in filesystems.

But disk files aren't the only source of bytestreams, so that doesn't
necessarily help us in the end.

> Arent there any libs for python to examine the contents (usually
> the first few bytes) for the type of the file?
 
I'm not aware of any for the general case.  There are a few things
like the imghdr module, but those are not for arbitrary files, and
likely aren't sufficiently capable.

I think there's a library from the Gnome desktop project for this
(basically providing something like the Unix "file" command), but I
don't know if there's a Python wrapper for the library, or an
all-Python re-implementation.


  -Fred

-- 
Fred L. Drake, Jr.    <fdrake at gmail.com>
Zope Corporation


More information about the Zope-Dev mailing list