instance method send_data

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v3.0.20

Available in: v2.2.3 v2.3.18 v3.0.20

Signature

send_data(data, options = {})

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.

Options:

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

  • :type - specifies an HTTP content type. Defaults to ‘application/octet-stream’.

  • :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.

Parameters

data req
options opt = {}
Source
# File actionpack/lib/action_controller/streaming.rb, line 128
      def send_data(data, options = {}) #:doc:
        logger.info "Sending data #{options[:filename]}" if logger
        send_file_headers! options.merge(:length => data.size)
        @performed_render = false
        render :status => options[:status], :text => data
      end

Defined in actionpack/lib/action_controller/streaming.rb line 128 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionController::Streaming

Type at least 2 characters to search.

↑↓ navigate · open · esc close