diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-02-24 12:29:25 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-02-24 12:29:25 +0000 |
commit | 53cd102b39eb62567298430cbd94e40dd78d46a0 (patch) | |
tree | 3d8a087421f0d74da7a7c3878e3ad1dddbf23697 /actionpack/lib/action_controller/streaming.rb | |
parent | e56b3e4c0b60b2b86f5ca9c5e5a0b22fa34d37ab (diff) | |
download | rails-53cd102b39eb62567298430cbd94e40dd78d46a0.tar.gz rails-53cd102b39eb62567298430cbd94e40dd78d46a0.tar.bz2 rails-53cd102b39eb62567298430cbd94e40dd78d46a0.zip |
Merge with docrails
Diffstat (limited to 'actionpack/lib/action_controller/streaming.rb')
-rw-r--r-- | actionpack/lib/action_controller/streaming.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/streaming.rb b/actionpack/lib/action_controller/streaming.rb index b6a6a2e5db..9f80f48c3d 100644 --- a/actionpack/lib/action_controller/streaming.rb +++ b/actionpack/lib/action_controller/streaming.rb @@ -1,5 +1,6 @@ module ActionController #:nodoc: - # Methods for sending files and streams to the browser instead of rendering. + # Methods for sending arbitrary data and for streaming files to the browser, + # instead of rendering. module Streaming DEFAULT_SEND_FILE_OPTIONS = { :type => 'application/octet-stream'.freeze, @@ -103,8 +104,11 @@ module ActionController #:nodoc: end end - # Send binary data to the user as a file download. May set content type, apparent file name, - # and specify whether to show data inline or download as an attachment. + # Sends the given binary data to the browser. This method is similar to + # <tt>render :text => data</tt>, but also allows you to specify whether + # the browser should display the response as a file attachment (i.e. in a + # download dialog) or as inline data. You may also set the content type, + # the apparent file name, and other things. # # Options: # * <tt>:filename</tt> - suggests a filename for the browser to use. @@ -127,6 +131,10 @@ module ActionController #:nodoc: # send_data image.data, :type => image.content_type, :disposition => 'inline' # # See +send_file+ for more information on HTTP Content-* headers and caching. + # + # <b>Tip:</b> if you want to stream large amounts of on-the-fly generated + # data to the browser, then use <tt>render :text => proc { ... }</tt> + # instead. See ActionController::Base#render for more information. def send_data(data, options = {}) #:doc: logger.info "Sending data #{options[:filename]}" if logger send_file_headers! options.merge(:length => data.size) |