The SendFile module can be used to stream a file to the user’s computer. While the performance of the module isn’t optimal it’s convenient and relatively easy to use.
The send_file method streams the specified file to the user’s browser.
@param [String] filename The name or path to the file which will be
streamed to the user.
@param [String] content_type The type of file we’re dealing with. For
example, if we want to stream a JPG image we'd set this variable to 'image/jpg'.
@param [String] content_disposition Value for the Content-Disposition
header.
# File lib/ramaze/helper/send_file.rb, line 20 20: def send_file(filename, content_type = nil, content_disposition = nil) 21: content_type ||= Rack::Mime.mime_type(::File.extname(filename)) 22: content_disposition ||= File.basename(filename) 23: 24: response.body = ::File.open(filename, 'rb') 25: response['Content-Length'] = ::File.size(filename).to_s 26: response['Content-Type'] = content_type 27: response['Content-Disposition'] = content_disposition 28: response.status = 200 29: 30: throw(:respond, response) 31: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.