python: determine file type by its content (not only by its magic)

335 views Asked by At

So I'm trying to verify that files I'm getting (uploaded by the user) are indeed images, and valid.

I'm running ClamAV (using python's clamd package) but it doesn't give back the actual file content.

I'm using python's magic package in order to check the magic file prefix (as imghdr also does for images), But my worry is for files with image magic prefix that contains JS code for example.

Any idea about how can I scan the uploaded file's content in order to determine its type ?

Thank you

0

There are 0 answers