Feature Proposal: Preserve Content-Type from HTTP form upload in attachment
Motivation
When HTTP transfers files, a MIME header always accompanies the file. This includes files uploaded in forms in addition to documents downloaded from a web server. One of the important pieces of information in the MIME header is the Content-Type, or the type of the file. Currently when attaching a file to a topic, TWiki does essentially this:
- Receive the file from the browser
- Discard the type information included with the file and save the file
And then when someone gets the file it attempts to guess what the type of the file was based on a suffix of the name. This is silly. Why not just preserve the filetype originally included with the file when it was uploaded?
Description
When an attachment is uploaded to a topic, the Content Type is retreived and saved along with the file. When using a web server such as Apache, using this feature, the original filetype is returned to the user and there is no need to guess it.
When showing a list of attachments, which icon to display to the left of the file is determined from its filetype instead of being guessed from its name.
When editing an attachment, the filetype can be changed.
--
PhillipVandry - 22 Feb 2005
Impact and Available Solutions
Documentation
The role of the _filetypes.txt file must change; it becomes a mapping from filetype to image instead of a mapping from name patterns to image.
If the web server does not support CERN style metafiles as mentioned above, the behaviour will revert to the web server guessing the type of the file based on the suffix of its name. This is no different than what happens without this patch.
I also created a topic
PreserveFileTypes before I noticed that that is the old workflow. I expect this topic should replace it?
yes. I deleted the old topic. Though for future reference, you could have just changed the form. Look for "replace form" in light gray text beside the form name while in edit mode. It doesn't look like a link but it is. -- MattWilkie - 23 Feb 2005
Examples
Implementation
Discussion:
Added Phillip's name to the contributor field as he supplied the code to fulfill his feature request. Thanks Phillip!
--
MattWilkie - 23 Feb 2005