algoo / preview-generator

generates previews of files with cache management
https://pypi.org/project/preview-generator/
MIT License
228 stars 50 forks source link

docx file mimetype being returned as bytes causing get_preview_builder to throw exception #197

Closed jeremydefibaugh closed 4 years ago

jeremydefibaugh commented 4 years ago

Wondering if this is just me or not..

in PreviewBuilderFactory.get_file_mimetype:

str_, encoding = mimetypes_storage.guess_type(first_path, strict=False) returns (None, None) for a docx file.

So then https://github.com/algoo/preview-generator/blob/develop/preview_generator/preview/builder_factory.py#L67-L69 returns the mimetype in bytes, causing get_preview_builder to fail.

I found that not calling MimeTypes() here https://github.com/algoo/preview-generator/blob/develop/preview_generator/extension.py fixes it.

Thinking it could be issues with my version of mimetype, or magic? Using Python 3.7.5

jeremydefibaugh commented 4 years ago

Resolved.. turns out the issue was an old version of python-magic..