openstreetmap-website/config/initializers/streaming.rb

19 lines
621 B
Ruby

# Hack ActionController::DataStreaming to allow streaming from a file handle
module ActionController
module DataStreaming
alias_method :old_send_file, :send_file
def send_file(file, options = {})
if file.is_a? File or file.is_a? Tempfile
options[:filename] ||= File.basename(file.path) unless options[:url_based_filename]
send_file_headers! options
self.status = options[:status] || 200
self.content_type = options[:content_type] if options.key?(:content_type)
self.response_body = file
else
old_send_file(file, options)
end
end
end
end