Forum OpenACS Development: Re: primary key in cr_mime_types

Posted by Janine Ohmer on
Mark, I just ran into this yesterday and came to the same conclusion you did.  However, Jeff Davis says

"The problem is that the cr_mime_types table is not (and should not be) a mapping table of extension to mime type.  Extension happens to be in the table but it is really a list of existing mime types.

There needs to be a table cr_extension_mime_type_map which handles this mapping and the mime type creation stuff should not be creating a mime type if one already exists."

(I hope he won't mind my posting his note - but he's asleep at the moment and can't do it himself :)

He said he was going to fix this but I don't know exactly when.

Posted by Jeff Davis on
I have created the table and have some data for populating it but the question is should we just quit using ns_guesstype and maintain it all ourselves. I looked at the raw data for ns_guesstype and it is wrong in some cases (like .zip -> application/x-zip-compressed rather than application/zip which iana lists) and is missing a lot of what people really upload (all the MS mime types for example), and has some DCI/AOL internal ones (or ones I have never seen anyway like .ani mapping to application/x-navi-animation). It can of course be overridden but maybe it would be better to maintain our own.

Also, lists about a zillion mime types and I wonder if we should just create most of them by default (which would mean tracking down extensions for most of them).

Another issue is that as it stands I have defined the table as:

create table cr_extension_mime_type_map (
   file_extension       varchar(200) 
                        constraint cr_mime_type_extension_map_pk
                        primary key,
   mime_type            varchar(200) 
                        constraint cr_mime_ext_map_mime_type_ref
                        references cr_mime_types
which would mean a unique entry per extension. I know it's not really valid but I think until we do the work on the UI side to allow for chosing the correct mime type it's probably better to enforce uniqueness.

The final one is that for some things I am not sure what the right generic extension to return would be when more than one is listed (the ext in cr_mime_types). An example being application/quicktime where both .qt and .mov are used.

Anyone want to figure it all out for me?