Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v3.0.9) is shown here.

These similar methods exist in v4.0.2:

send_data(data, options = {}) protected

Sends the given binary data to the browser. This method is similar to render :text => data, 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.


  • :filename - suggests a filename for the browser to use.

  • :type - specifies an HTTP content type. Defaults to ‘application/octet-stream’. You can specify either a string or a symbol for a registered type register with Mime::Type.register, for example :json

  • :disposition - specifies whether the file will be shown inline or downloaded. Valid values are ‘inline’ and ‘attachment’ (default).

  • :status - specifies the status code to send with the response. Defaults to ‘200 OK’.

Generic data download:

send_data buffer

Download a dynamically-generated tarball:

send_data generate_tgz('dir'), :filename => 'dir.tgz'

Display an image Active Record in the browser:

send_data image.data, :type => image.content_type, :disposition => 'inline'

See send_file for more information on HTTP Content-* headers and caching.

Tip: if you want to stream large amounts of on-the-fly generated data to the browser, then use render :text => proc { ... } instead. See ActionController::Base#render for more information.

Show source
Register or log in to add new notes.