end
return tmp
end
+
+ # Returns a string that can be used as filename value in Content-Disposition header
+ def filename_for_content_disposition(name)
+ request.env['HTTP_USER_AGENT'] =~ %r{MSIE} ? ERB::Util.url_encode(name) : name
+ end
end
def download
# images are sent inline
- send_file @attachment.diskfile, :filename => @attachment.filename,
+ send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => @attachment.content_type,
:disposition => (@attachment.image? ? 'inline' : 'attachment')
rescue
def download
@attachment = @document.attachments.find(params[:attachment_id])
@attachment.increment_download
- send_file @attachment.diskfile, :filename => @attachment.filename, :type => @attachment.content_type
+ send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
+ :type => @attachment.content_type
rescue
render_404
end
def download
@attachment = @version.attachments.find(params[:attachment_id])
@attachment.increment_download
- send_file @attachment.diskfile, :filename => @attachment.filename, :type => @attachment.content_type
+ send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
+ :type => @attachment.content_type
rescue
render_404
end