X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/52e5fa6ad78f375cec5a207a123a4aa3939c8ddf..92384ed9565d6f6558417ea43958612cbf9a87d7:/config/initializers/streaming.rb diff --git a/config/initializers/streaming.rb b/config/initializers/streaming.rb index 0fc092951..3db2a55f9 100644 --- a/config/initializers/streaming.rb +++ b/config/initializers/streaming.rb @@ -4,7 +4,9 @@ module ActionController alias_method :old_send_file, :send_file def send_file(file, options = {}) - if file.is_a? File or file.is_a? Tempfile + if file.is_a?(File) || file.is_a?(Tempfile) + headers["Content-Length"] ||= file.size.to_s + options[:filename] ||= File.basename(file.path) unless options[:url_based_filename] send_file_headers! options @@ -12,6 +14,8 @@ module ActionController self.content_type = options[:content_type] if options.key?(:content_type) self.response_body = file else + headers["Content-Length"] ||= File.size(file).to_s + old_send_file(file, options) end end