Skip to content

Determine mimetype according to filename instead of contents, if possible

The previous approach to determine the real mimetype of a downloaded file used both file name and file contents, keeping the former only if it inherited the latter. This, however, can cause problems for mimetypes created by the user, as they don't usually contain inheritance information. To avoid this issue, Now the file contents are used only if the mimetype can't be determined from the file name. This isn't ideal, however, since in this case the file name is most likely chosen according to the one suggested by the server, which may be wrong.

I noticed this problem handling GeoGebra files. They are a special kind of zip files which I wanted opened in the GeoGebra application. I used the "File associations" KCM to create a application/geogebra file type with extension .ggb and added GeoGebra as the application to open them. However, the KCM doesn't provide a way to tell the system that the application/geogebra mimetype should inherit application/zip. When I download a GeoGebra file, the mimetype determined from the name is, correctly, application/geogebra. Since there's no rule to determine GeoGebra files from their contents, however, the mimetype determined from contents is application/zip: this means that the resulting mimetype will be application/zip and the file will be opened in Ark rather than in GeoGebra.

Merge request reports