scm: set mime type in downloading file.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5210 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3ee44b363c
commit
be2046b189
@ -127,7 +127,10 @@ class RepositoriesController < ApplicationController
|
|||||||
(@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
|
(@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
|
||||||
! is_entry_text_data?(@content, @path)
|
! is_entry_text_data?(@content, @path)
|
||||||
# Force the download
|
# Force the download
|
||||||
send_data @content, :filename => filename_for_content_disposition(@path.split('/').last)
|
send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
|
||||||
|
send_type = Redmine::MimeType.of(@path)
|
||||||
|
send_opt[:type] = send_type.to_s if send_type
|
||||||
|
send_data @content, send_opt
|
||||||
else
|
else
|
||||||
# Prevent empty lines when displaying a file with Windows style eol
|
# Prevent empty lines when displaying a file with Windows style eol
|
||||||
# TODO: UTF-16
|
# TODO: UTF-16
|
||||||
|
@ -98,8 +98,7 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase
|
|||||||
with_settings :file_max_size_displayed => 1 do
|
with_settings :file_max_size_displayed => 1 do
|
||||||
get :entry, :id => PRJ_ID, :path => ['japanese', 'big-file.txt']
|
get :entry, :id => PRJ_ID, :path => ['japanese', 'big-file.txt']
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# TODO: 'text/plain'
|
assert_equal 'text/plain', @response.content_type
|
||||||
assert_equal 'application/octet-stream', @response.content_type
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -222,8 +222,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
|
|||||||
def test_entry_binary_force_download
|
def test_entry_binary_force_download
|
||||||
get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png']
|
get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png']
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# TODO: 'image/png'
|
assert_equal 'image/png', @response.content_type
|
||||||
assert_equal 'application/octet-stream', @response.content_type
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_directory_entry
|
def test_directory_entry
|
||||||
|
Loading…
x
Reference in New Issue
Block a user