module Sinatra::Helpers
def attachment(filename = nil, disposition = 'attachment')
Set the Content-Disposition to "attachment" with the specified filename,
def attachment(filename = nil, disposition = 'attachment') response['Content-Disposition'] = disposition.to_s if filename params = '; filename="%s"' % File.basename(filename) response['Content-Disposition'] << params ext = File.extname(filename) content_type(ext) unless response['Content-Type'] or ext.empty? end end