Edgewall Software
Modify

Opened 16 years ago

Last modified 10 years ago

#7724 new enhancement

Allow user provided mime-type for attachments

Reported by: martin@… Owned by:
Priority: low Milestone: next-major-releases
Component: attachment Version: 0.12dev
Severity: major Keywords: excel word powerpoint office MicrosoftOffice MSOffice DOCX XLSX mime-type mimeviewer mime_map ZIP OpenXML IE InternetExplorer Office2007 PPTX
Cc: martin@…, Ryan J Ollos Branch:
Release Notes:
API Changes:
Internal Changes:

Description

While for svn repository files the 'svn:mime-type' property can be used there is no way to explicit provide the mime-type for wiki attachments.

The files which mime-type is not automatically detected by Trac can not be correct inline displayed when the mime-type isn't provided by the user. For source files the correct svn:mime-type can be set, but not for attachments.

This affects e.g. plugins implementing IHTMLPreviewRenderer for non-standard mime-types. Here the plugin isn't used for attachments because of the missing correct mime-type.

Question: Is there a possibility to register a file extension with a curtain mime-type, without hacking /trac/mimeview/api.py?

Attachments (0)

Change History (14)

comment:1 by Matthew Good, 16 years ago

Priority: highnormal
Type: defectenhancement

The admin can map extensions to mime types using the mime_map option in the [mimeviewer] section of trac.ini (see TracIni#mimeviewer-section)

comment:2 by martin@…, 16 years ago

Thanks for the hint mgood, mime_map seems to work with my IHTMLPreviewRenderer plugin.

(But there should be still the possibility to provide the mime-type on a per-file base for attachments.)

comment:3 by Remy Blank, 16 years ago

Keywords: consider added
Milestone: 2.0

A mime-type selector could be provided on the "Add attachment" page. Do you have a concrete use case where the mime-type should be selectable for every file, or did comment:1 solve your issues?

comment:4 by martin@…, 16 years ago

Cc: martin@… added

The tip mentioned in comment:1 solved my problem.

But IMHO there should be a mime-type selector at the "Add attachment" page, just in case for some special file formats which can't be identified by the file extension, e.g. sometimes the same extensions are used for different file types.

in reply to:  4 ; comment:5 by anonymous, 16 years ago

Keywords: excel XLSX mime type mime_map added; consider removed
Version: 0.12dev

This did not solve my issue. I have users uploading DOCX and XLSX files. In Firefox and Opera downloading works fine. But most have IE and it attempts to download as a ZIP file. Very odd. I changed the mime_map to the following but no joy.

mime_map = text/x-dylan:dylan,text/x-idl:ice,text/x-ada:ads:adb,application/msexcel:xlam:xlsb:xlsm:xltm:xlsx:xltx,application/ms-powerpoint:ppam:potm:pptm:ppsm:pptx:ppsx:potx,application/msword:docm:dotm:docx:dotx

comment:6 by Christian Boos, 16 years ago

While we're at it, it should be possible to also specify the encoding of a given attachment.

comment:7 by Ryan Ollos <ryano@…>, 15 years ago

Cc: ryano@… added
Keywords: word office DOCX ZIP added

in reply to:  5 comment:8 by Ryan Ollos <ryano@…>, 15 years ago

Replying to anonymous:

This did not solve my issue. I have users uploading DOCX and XLSX files. In Firefox and Opera downloading works fine. But most have IE and it attempts to download as a ZIP file. Very odd. I changed the mime_map to the following but no joy.

mime_map = text/x-dylan:dylan,text/x-idl:ice,text/x-ada:ads:adb,application/msexcel:xlam:xlsb:xlsm:xltm:xlsx:xltx,application/ms-powerpoint:ppam:potm:pptm:ppsm:pptx:ppsx:potx,application/msword:docm:dotm:docx:dotx

The following is working well for me,

[mimeviewer]
mime_map = application/vnd.ms-word.document.macroEnabled.12:docm,
application/vnd.openxmlformats-officedocument.wordprocessingml.document:docx,
application/vnd.ms-word.template.macroEnabled.12:dotm,
application/vnd.openxmlformats-officedocument.wordprocessingml.template:dotx,
application/vnd.ms-powerpoint.template.macroEnabled.12:potm,
application/vnd.openxmlformats-officedocument.presentationml.template:potx,
application/vnd.ms-powerpoint.addin.macroEnabled.12:ppam,
application/vnd.ms-powerpoint.slideshow.macroEnabled.12:ppsm,
application/vnd.openxmlformats-officedocument.presentationml.slideshow:ppsx,
application/vnd.ms-powerpoint.presentation.macroEnabled.12:pptm,
application/vnd.openxmlformats-officedocument.presentationml.presentation:pptx,
application/vnd.ms-excel.addin.macroEnabled.12:xlam,
application/vnd.ms-excel.sheet.binary.macroEnabled.12:xlsb,
application/vnd.ms-excel.sheet.macroEnabled.12:xlsm,
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:xlsx,
application/vnd.ms-excel.template.macroEnabled.12:xltm,
application/vnd.openxmlformats-officedocument.spreadsheetml.template:xltx

References:

  1. http://www.bram.us/2007/05/25/office-2007-mime-types-for-iis/
  2. http://webdeveloper.com/forum/showthread.php?t=162526
  3. http://msdn.microsoft.com/en-us/library/ms775147(VS.85).aspx

comment:9 by Ryan Ollos <ryano@…>, 15 years ago

Keywords: powerpoint MicrosoftOffice MSOffice mime-type mimeviewer OpenXML IE InternetExplorer Office2007 PPTX added; mime type removed

Another solution that I tested out which worked well was to change the svn:mime-type for the file from application/octet-stream to the corresponding application/vnd.* entry that it matched in the above list. Setting the mime_map property is the easier solution since it affects all of the files downloaded from Trac, but I mention the other solution in case it might be useful for someone who doesn't have administrative rights to the server and wants a quick solution to the file download issue.

in reply to:  4 ; comment:10 by Ryan Ollos <ryano@…>, 15 years ago

Replying to martin@…:

The tip mentioned in comment:1 solved my problem.

But IMHO there should be a mime-type selector at the "Add attachment" page, just in case for some special file formats which can't be identified by the file extension, e.g. sometimes the same extensions are used for different file types.

If this was added I'd vote for a trac.ini configuration parameter to show/hide the mime_type_selector and also the proposed encoding_type_selector, just for the sake of keeping Trac configurable in a light-weight mode with minimal options, which in some cases confuse certain end-users.

comment:11 by Christian Boos, 15 years ago

Milestone: 2.0unscheduled

Milestone 2.0 deleted

comment:12 by Christian Boos, 14 years ago

Milestone: triagingnext-major-0.1X
Priority: normallow

(for comment:3)

in reply to:  10 comment:13 by Martin Scharrer <martin@…>, 14 years ago

Replying to Ryan Ollos <ryano@…>:

Replying to martin@…:

The tip mentioned in comment:1 solved my problem.

But IMHO there should be a mime-type selector at the "Add attachment" page, just in case for some special file formats which can't be identified by the file extension, e.g. sometimes the same extensions are used for different file types.

If this was added I'd vote for a trac.ini configuration parameter to show/hide the mime_type_selector and also the proposed encoding_type_selector, just for the sake of keeping Trac configurable in a light-weight mode with minimal options, which in some cases confuse certain end-users.

I agree with you here. Alternatively there could be an initial folded section like 'Further options' or 'Advanced options'. This would hide it from the normal user, but doesn't remove it completely.

comment:15 by Ryan J Ollos, 10 years ago

Cc: Ryan J Ollos added; ryano@… removed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.