Allow a mimetype to map to multiple extensions

Bug #1438487 reported by Robert Lyon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Confirmed
Wishlist
Unassigned

Bug Description

Currently a mimetype can only map to one extension. But some extensions like .wmv can be handled by video/x-ms-asf (but that is mapped to .asf)

It would be better if we could have a one (mimetype) to many (extensions) relationship

This would be also good for .jpg and .jpeg mapping to jpeg mimetype

Revision history for this message
Robert Lyon (robertl-9) wrote :
Revision history for this message
Aaron Wells (u-aaronw) wrote :

As we discussed on IRC, we need to allow multiple file extensions to map to the same mimetype. Currently, we use the table "artefact_file_mime_types", which has two columns, "mimetype" and "description". The mimetype column is the primary key, which means that it allows multiple mimetypes to be mapped to the same "description", which is the wrong way round from what we need.

Also, the "description" column is not *strictly* a file extension. For instance, "mp4_video" and "mp4_audio" are in there, indicating an mp4 file used for video or audio.

I believe this is mostly a holdover from our older mimetype detection system, where we'd rely on fileinfo() or magicdb or the browser. But as of Bug 1302251, we now use the file extension *first*, and the other methods as a fallback.

Probably the most sensible thing to do would be:

1. Flip "artefact_file_mime_types" so that you can have multiple file extensions to the same mimetype.

2. Change "description" into "file extension". (And assume that all mp4 files are video.)

3. Maybe add a second table of "auxiliary mimetypes" that let you say things like "application/x-zip" = "application/zip". So that we can still fallback to detecting the mimetype via finfo and magicdb.

4. Although honestly... I'm really tempted to just do things the same as Moodle. Don't bother detecting mimetypes at all via finfo, magicdb, or the browser. Just rely entirely on file extensions. It does seem to be the most robust way to go.

5. Anyway, after we update the table structures and their data so that multiple file extensions can map to the same mimetype, add a section to artefact/file/db/upgrade.php to find all the file artefacts whose mimetype should be changed based on their file extension, and update them. (In order to avoid redundancy, you can delete the similar upgrade we did for archive filetypes, which is also in artefact/file/db/upgrade.php)

Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 15.10.0 → 16.04.0
Changed in mahara:
milestone: 16.04.0 → none
Changed in mahara:
importance: Medium → Wishlist
summary: - Sort out mimetypes - allow a mimetype map to multiple extensions
+ Allow a mimetype to map to multiple extensions
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.