Edgewall Software
Modify

Opened 6 years ago

Last modified 4 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@…, ryano@…
Release Notes:
API 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 (13)

comment:1 Changed 6 years ago by mgood

  • Priority changed from high to normal
  • Type changed from defect to enhancement

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 Changed 6 years ago by martin@…

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 Changed 5 years ago by rblank

  • Keywords consider added
  • Milestone set to 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 follow-ups: Changed 5 years ago by martin@…

  • 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.

comment:5 in reply to: ↑ 4 ; follow-up: Changed 5 years ago by anonymous

  • Keywords excel XLSX mime type mime_map added; consider removed
  • Version set to 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 Changed 5 years ago by cboos

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

comment:7 Changed 5 years ago by Ryan Ollos <ryano@…>

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

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

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 Changed 5 years ago by Ryan Ollos <ryano@…>

  • 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.

comment:10 in reply to: ↑ 4 ; follow-up: Changed 5 years ago by 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.

comment:11 Changed 4 years ago by cboos

  • Milestone changed from 2.0 to unscheduled

Milestone 2.0 deleted

comment:12 Changed 4 years ago by cboos

  • Milestone changed from triaging to next-major-0.1X
  • Priority changed from normal to low

(for comment:3)

comment:13 in reply to: ↑ 10 Changed 4 years ago by Martin Scharrer <martin@…>

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new The ticket will remain with no owner.
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'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.