ahupp / python-magic

A python wrapper for libmagic
Other
2.64k stars 283 forks source link

docx recognized as zip, MacOS #215

Closed cicihou closed 4 years ago

cicihou commented 4 years ago

    docx = 'https://ym-ow.s3.cn-north-1.amazonaws.com.cn/attachments/1589875593-1588909884-E8AFB4E6988EE4B9A6E585B7E4BD93E8A681E6B182.docx'
    r_img = requests.get(url)
    b = r_img.content
    print(magic.from_buffer(b, mime=True))
ahupp commented 4 years ago

This is dependent on the version of libmagic you are using and/or the magic definition file. e.g, with debian bullseye (libmagic 5.38) I get this:

magic.from_buffer(open('1589875593-1588909884- E8AFB4E6988EE4B9A6E585B7E4BD93E8A681E6B182.docx', 'br').read(), mime=True) 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'