Patch #3782

broken downloads of attached files after trac import due to missing mime type definitions

Added by he buiss about 8 years ago. Updated almost 8 years ago.

Status:ClosedStart date:2009-08-26
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Importers
Target version:0.9.0

Description

After importing my Trac data to redmine via "migrate_from_trac" I noticed that several files, which have been attached to tickets, cannot be downloaded correctly due to wrong mime type information.

The problem is that several files have no information in column "file_type" of redmine's "attachment" table. This information is being generated by "Redmine::MimeType.of(filename)" which is described in file /lib/redmine/mime_type.rb .

My suggestion is, to add some more mime types to this definition:

    MIME_TYPES = {
      'text/plain' => 'txt,tpl,properties,patch,diff,ini,readme,install,upgrade',
      'text/css' => 'css',
      'text/html' => 'html,htm,xhtml',
      'text/jsp' => 'jsp',
    ...

The ones, I added, were:

      'application/msword' => 'doc',
      'application/vnd.ms-excel' => 'xls',
      'application/vnd.ms-powerpoint' => 'ppt',
      'application/vnd.ms-powerpoint' => 'pps',
      'application/vnd.oasis.opendocument.text' => 'odt',
      'application/vnd.oasis.opendocument.presentation' => 'odp',
      'application/vnd.oasis.opendocument.spreadsheet' => 'ods',
      'application/pdf' => 'pdf',
      'application/rtf' => 'rtf',
      'application/zip' => 'zip',
      'application/x-rar-compressed' => 'rar',
      'application/x-tar' => 'tar',

A nice collection of mime types can be found here: http://de.selfhtml.org/diverses/mimetypen.htm#uebersicht

new_mime_types.patch Magnifier - Support more mime-types (2.89 KB) Babar O'Cap, 2009-09-21 17:43

Associated revisions

Revision 3258
Added by Jean-Philippe Lang almost 8 years ago

Auto-detect attachment content type when blank (#3782).

Revision 3281
Added by Jean-Philippe Lang almost 8 years ago

Fixed: error when downloading a file with no matching mime type (#3782).

History

#1 Updated by Babar O'Cap about 8 years ago

+1

#2 Updated by Babar O'Cap about 8 years ago

Here a patch with new mime types :
doc, xls, ppt, pps, docx, xlsx, ppsx, pptx, 7zip, odt, ods, odp, csv ...

#3 Updated by Andrea Campi almost 8 years ago

+1, this is a small issue but a boring one.

#4 Updated by Jean-Philippe Lang almost 8 years ago

  • Status changed from New to Resolved
  • Target version set to 0.9.0

See r3258.

#5 Updated by Andrea Campi almost 8 years ago

Actually, I was wrong, it seems for me (or rather, for one of users) Attachment.content_type is not null, but it contains 'text/html' instead of 'application/pdf'.
Off to debug this some more...

The commit does look good though :)

#6 Updated by Berk Demirkır almost 8 years ago

r3258 causes Internal Error when downloading mime-typeless files. I've just reverted back and it works fine. (filename was a43)

#7 Updated by Berk Demirkır almost 8 years ago

I should note that my database was working on 0.8.7 version of Redmine. I've switched to trunk a week ago. All content_types are blank.

In log files, I was getting this error

ArgumentError (:type option required):
  app/controllers/attachments_controller.rb:43:in `download'

#8 Updated by Jean-Philippe Lang almost 8 years ago

Berk Demirkır wrote:

r3258 causes Internal Error when downloading mime-typeless files. I've just reverted back and it works fine. (filename was a43)

Fixed in r3281.

#9 Updated by Jean-Philippe Lang almost 8 years ago

  • Status changed from Resolved to Closed

Merged in 0.9-stable in r3286.

Also available in: Atom PDF