in reply to how to read content-type from a file?
The MIME-Types-0.06 module provides a way to determine the MIME-types of your files.
It's seems fairly easy, although I haven't used it myself.