lib/plezi/controller/controller.rb
def send_data(data, options = {})
         response.write data if data
         filename = options[:filename]
         # set headers
         content_disposition = options[:inline] ? 'inline'.dup : 'attachment'.dup
         content_disposition << "; filename=#{::File.basename(options[:filename])}" if filename
         cont_type = (options[:mime] ||= filename && Rack::Mime.mime_type(::File.extname(filename)))
         response['content-type'.freeze] = cont_type if cont_type
         response['content-disposition'.freeze] = content_disposition
         true
      end
def send_data(data, options = {})
         response.write data if data
         filename = options[:filename]
         # set headers
         content_disposition = options[:inline] ? 'inline'.dup : 'attachment'.dup
         content_disposition << "; filename=#{::File.basename(options[:filename])}" if filename
         cont_type = (options[:mime] ||= filename && Rack::Mime.mime_type(::File.extname(filename)))
         response['content-type'.freeze] = cont_type if cont_type
         response['content-disposition'.freeze] = content_disposition
         true
      end
def send_data ( data , options = { } ) response . write data if data filename = options [ :filename ] # set headers content_disposition = options [ :inline ] ? 'inline' . dup : 'attachment' . dup content_disposition << "; filename=#{::File.basename(options[:filename])}" if filename cont_type = ( options [ :mime ] ||= filename && Rack :: Mime . mime_type ( :: File . extname ( filename ) ) ) response [ 'content-type' . freeze ] = cont_type if cont_type response [ 'content-disposition' . freeze ] = content_disposition true end
Sends a block of data, setting a file name, mime type and content disposition headers when possible. This should also be a good choice when sending large amounts of data.

 By default, `send_data` sends the data as an attachment, unless `inline: true` was set.

 If a mime type is provided, it will be used to set the Content-Type header. i.e. `mime: "text/plain"`

 If a file name was provided, Rack will be used to find the correct mime type (unless provided). i.e. `filename: "sample.pdf"` will set the mime type to `application/pdf`

 Available options: `:inline` (`true` / `false`), `:filename`, `:mime`.
Sends a block of data setting a file name mime type and content disposition headers when possible . This should also be a good choice when sending large amounts of data .