]> git.openstreetmap.org Git - rails.git/blob - config/initializers/streaming.rb
Merge branch 'master' into openstreetbugs
[rails.git] / config / initializers / streaming.rb
1 # Hack ActionController::DataStreaming to allow streaming from a file handle
2 module ActionController
3   module DataStreaming
4     alias_method :old_send_file, :send_file
5
6     def send_file(file, options = {})
7       if file.is_a? File or file.is_a? Tempfile
8         options[:filename] ||= File.basename(file.path) unless options[:url_based_filename]
9         send_file_headers! options
10
11         self.status = options[:status] || 200
12         self.content_type = options[:content_type] if options.key?(:content_type)
13         self.response_body = file
14       else
15         old_send_file(file, options)
16       end
17     end
18   end
19 end