6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/carrierwave/postgresql_table/rack_app.rb', line 6
def call(env)
request = Rack::Request.new(env)
file = CarrierWave::Storage::PostgresqlTable::File.new(request.path.sub(/^\//, ""))
= {
"Last-Modified" => file.last_modified.httpdate,
"Content-Type" => file.content_type,
"Content-Disposition" => "inline",
}
if(request.params["download"] == "true")
["Content-Disposition"] = "attachment; filename=#{file.filename}"
end
body = Enumerator.new do |response_body|
while(chunk = file.read(READ_CHUNK_SIZE)) do
response_body << chunk
end
end
[200, , body]
end
|