Module: Tap::Controller::Utils
- Defined in:
- lib/tap/controller/utils.rb
Instance Method Summary collapse
Instance Method Details
#download(path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tap/controller/utils.rb', line 16 def download(path) content = File.read(path) headers = { "Last-Modified" => File.mtime(path).httpdate, "Content-Type" => Rack::Mime.mime_type(File.extname(path), 'text/plain'), "Content-Disposition" => "attachment; filename=#{File.basename(path)};", "Content-Length" => content.size.to_s } [200, headers, [content]] end |
#static_file(path) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/tap/controller/utils.rb', line 5 def static_file(path) content = File.read(path) headers = { "Last-Modified" => File.mtime(path).httpdate, "Content-Type" => Rack::Mime.mime_type(File.extname(path), 'text/plain'), "Content-Length" => content.size.to_s } [200, headers, [content]] end |