mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #25248
[Bug 1438487] Re: Sort out mimetypes - allow a mimetype map to multiple extensions
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)
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1438487
Title:
Sort out mimetypes - allow a mimetype map to multiple extensions
Status in Mahara ePortfolio:
Confirmed
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
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1438487/+subscriptions
References