1 # Hack ActionController::DataStreaming to allow streaming from a file handle
2 module ActionController
4 alias_method :old_send_file, :send_file
6 def send_file(file, options = {})
7 if file.is_a?(File) || file.is_a?(Tempfile)
8 headers["Content-Length"] ||= file.size.to_s
10 options[:filename] ||= File.basename(file.path) unless options[:url_based_filename]
11 send_file_headers! options
13 self.status = options[:status] || 200
14 self.content_type = options[:content_type] if options.key?(:content_type)
15 self.response_body = file
17 headers["Content-Length"] ||= File.size(file).to_s
19 old_send_file(file, options)