Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't generate xslx / ods preview: file preview not supported due to uncorrect mimetype guess #24

Closed
inkhey opened this Issue Sep 17, 2018 · 10 comments

Comments

Projects
None yet
2 participants
@inkhey
Copy link
Collaborator

inkhey commented Sep 17, 2018

Currently:

xlsx file mimetype is guess as "application/octet-stream".
all preview_generator method failed due to "UnsupportedMimeType"

Expected:

Support xlsx file normally (libreoffice builder is able to do it).

@lebouquetin

This comment has been minimized.

Copy link
Member

lebouquetin commented Sep 17, 2018

@inkhey do you have an example file? Do you have the extension in the file used in your code?
file extension is used as a fallback for mime guess

@lebouquetin

This comment has been minimized.

Copy link
Member

lebouquetin commented Sep 17, 2018

The problem also appears with a .ods file :
raw.ods.zip

note: please rename the file raw.ods.zip to raw.ods before test.

@lebouquetin lebouquetin changed the title Can't generate xslx preview: file preview not supported due to uncorrect mimetype guess Can't generate xslx / ods preview: file preview not supported due to uncorrect mimetype guess Sep 17, 2018

@inkhey

This comment has been minimized.

Copy link
Collaborator Author

inkhey commented Sep 19, 2018

@lebouquetin

This comment has been minimized.

Copy link
Member

lebouquetin commented Sep 19, 2018

@inkhey nice. What is the error with this file? Could you add the stacktrace of a simple preview test?. I mean... what is the mimetype detected (if the error is still a mimetype error)

@inkhey

This comment has been minimized.

Copy link
Collaborator Author

inkhey commented Sep 20, 2018

@lebouquetin I tried to reproduce using preview_generator only without success.

After debugging tracim issue with it, it seems that issue is related to bad combination of both preview-generator and filedepot in Tracim.

Filedepot store a file with a filename without any file extension. Example of filepath :

/tmp/tracim/backend/depot/c8dd06f2-bcc3-11e8-b293-4ccc6ab5724c/file

This filepath is given to preview_generator, who don't success to guess filetype.

@lebouquetin

This comment has been minimized.

Copy link
Member

lebouquetin commented Sep 20, 2018

@inkhey i'm pretty sure this problem has been resolved in tracim v1 by adding file extension parameter to preview generator API, so that file depot and preview-generator work well together.

Did you re-use the code from tracim v1 or did you rewrite it?

@inkhey

This comment has been minimized.

Copy link
Collaborator Author

inkhey commented Sep 20, 2018

@lebouquetin tracimv2 preview code is inspired from tracim v1 but it's possible that some logic may be forgotten.

I check a bit source code of preview_generator but i don't see anything about specifying file extension from preview_generator API in a specific params, and adding an invalid file path seems a strange behaviour.

I tried also xlsx file in tracimv1 and preview doesn't seems to work.

@lebouquetin

This comment has been minimized.

Copy link
Member

lebouquetin commented Sep 20, 2018

@inkhey you wont give an invalid path. You will give:

get_preview(
    path = '/tmp/tracim/backend/depot/c8dd06f2-bcc3-11e8-b293-4ccc6ab5724c/file',
    extension = 'xlsx'
)

If there are nothing about that in source code... let me sometime in order to check - maybe a POC I did not push... I take the issue

@lebouquetin lebouquetin self-assigned this Sep 20, 2018

@inkhey

This comment has been minimized.

Copy link
Collaborator Author

inkhey commented Sep 20, 2018

@lebouquetin don't see anything about extension here : https://github.com/algoo/preview-generator/blob/master/preview_generator/manager.py .
It's required not only to "get preview" but also to get informations like page_nb or for think like has_pdf_preview.

@lebouquetin

This comment has been minimized.

Copy link
Member

lebouquetin commented Sep 20, 2018

Actually, this parameter has to be added to the get_file_mimetype() method of the factory and to be added as an optionnal parameter to the manager apis.

I'm pretty sure to have done this job somewhere...

lebouquetin pushed a commit that referenced this issue Sep 24, 2018

Damien Accorsi
#24: allow to force file extension when using manager - in order to a…
…void (wrong) auto-detection of mimetype. This allow to work with files stored without extension in filename (this is the case when using file depot)

basilelegal added a commit that referenced this issue Oct 11, 2018

@buxx buxx closed this in #33 Oct 11, 2018

buxx added a commit that referenced this issue Oct 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.