##// END OF EJS Templates
Don't force download of PDF (#22483)....
Jean-Philippe Lang -
r15027:3e776af8066e
parent child
Show More
@@ -59,7 +59,7 class AttachmentsController < ApplicationController
59 59 # images are sent inline
60 60 send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
61 61 :type => detect_content_type(@attachment),
62 :disposition => (@attachment.image? ? 'inline' : 'attachment')
62 :disposition => disposition(@attachment)
63 63 end
64 64 end
65 65
@@ -191,4 +191,12 class AttachmentsController < ApplicationController
191 191 end
192 192 content_type.to_s
193 193 end
194
195 def disposition(attachment)
196 if attachment.is_image? || attachment.is_pdf?
197 'inline'
198 else
199 'attachment'
200 end
201 end
194 202 end
@@ -173,7 +173,7 class RepositoriesController < ApplicationController
173 173 send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
174 174 send_type = Redmine::MimeType.of(@path)
175 175 send_opt[:type] = send_type.to_s if send_type
176 send_opt[:disposition] = (Redmine::MimeType.is_type?('image', @path) ? 'inline' : 'attachment')
176 send_opt[:disposition] = disposition(@path)
177 177 send_data @repository.cat(@path, @rev), send_opt
178 178 else
179 179 if !@entry.size || @entry.size <= Setting.file_max_size_displayed.to_i.kilobyte
@@ -441,4 +441,12 class RepositoriesController < ApplicationController
441 441 )
442 442 graph.burn
443 443 end
444
445 def disposition(path)
446 if Redmine::MimeType.is_type?('image', @path) || Redmine::MimeType.of(@path) == "application/pdf"
447 'inline'
448 else
449 'attachment'
450 end
451 end
444 452 end
@@ -245,6 +245,10 class Attachment < ActiveRecord::Base
245 245 self.filename =~ /\.(patch|diff)$/i
246 246 end
247 247
248 def is_pdf?
249 Redmine::MimeType.of(filename) == "application/pdf"
250 end
251
248 252 # Returns true if the file is readable
249 253 def readable?
250 254 File.readable?(diskfile)
General Comments 0
You need to be logged in to leave comments. Login now