Finding MIME type for a data stream

Tobiah toby at tobiah.org
Thu Mar 8 16:55:06 EST 2012


I'm pulling image data from a database blob, and serving
it from a web2py app.  I have to send the correct
Content-Type header, so I need to detect the image type.

Everything that I've found on the web so far, needs a file
name on the disk, but I only have the data.

It looks like the 'magic' package might be of use, but
I can't find any documentation for it.

Also, it seems like image/png works for other types 
of image data, while image/foo does not, yet I'm afraid
that not every browser will play along as nicely.

Thanks!

Tobiah



More information about the Python-list mailing list