You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to check the extension and return the mime types for files with extensions like .xlsx, .xls, etc. But whenever I am trying to detect it using from_string() function, it is returning .docx as extension and 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' as the mime type. Though from_file() is returning the correct response but still for my use case I wanted to use from_string(). even I tried to write the .xlsx file to a temp file still it is returning .docx as extension unless I explicitly mention the suffix for the temp file.
Pure magic only detects files by two methods, first is magic number, which you can see all those file types have the same PK\x03\x04 , and the extension.
Unfortunately Microsoft decided that XLSX and other office files should just be zips (can take any XLSX and unzip them to see) and so it matches any other ZIP magic number.
Would need more advanced file scanning techniques to determine the actual file type, #3
I wanted to check the extension and return the mime types for files with extensions like .xlsx, .xls, etc. But whenever I am trying to detect it using from_string() function, it is returning .docx as extension and 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' as the mime type. Though from_file() is returning the correct response but still for my use case I wanted to use from_string(). even I tried to write the .xlsx file to a temp file still it is returning .docx as extension unless I explicitly mention the suffix for the temp file.
I ran magic_stream() on the file and I received following as the output:
The text was updated successfully, but these errors were encountered: