I am trying to identify the file type of the files uploaded, after searching, I plan to use the python-magic to check the mime types of a file.
The FileField
is used in my models, a ModelForm
is used to help save the files.
After all the files have been uploaded, I check the mime type in my python shell
I find that using
magic.from_file("path_to_the_file", mime=True)
woud give the expected mime type for image,txt,pdf files that have been saved.
However, for all the docx, ppt, excel files, it would identify them as 'application/zip'
Can anyone explain why this is happening(the django auto save the ms files as zip??). And is there any good way to make the magic identify the docx, ppt, excel files as they are?
Thank you very much.