3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/sinatra/xsendfile.rb', line 3
def x_send_file(path, opts = {})
if opts[:type] or not response['Content-Type']
content_type(opts[:type] || File.extname(path) || 'application/octet-stream')
end
if opts[:disposition] == 'attachment' || opts[:filename]
attachment opts[:filename] || path
elsif opts[:disposition] == 'inline'
response['Content-Disposition'] = 'inline'
end
= opts[:header] || (settings.respond_to?(:xsf_header) && settings.) ||
'X-SendFile'
if == 'X-Accel-Redirect'
public_folder = if settings.respond_to?(:public_folder)
settings.public_folder
else
settings.public
end
path = File.expand_path(path).gsub(public_folder, '')
end
response[] = path
halt
rescue Errno::ENOENT
not_found
end
|