15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/bcms_s3/s3_module.rb', line 15
def show_with_s3
@attachment = ::Attachment.find(params[:id])
@attachment = @attachment.as_of_version(params[:version]) if params[:version]
if Cms::S3.enabled
if Cms::S3.options[:s3_cname]
redirect_to("http://#{Cms::S3.options[:s3_cname]}/#{@attachment.file_location}")
else
redirect_to("http://#{Cms::S3.options[:bucket]}.s3.amazonaws.com/#{@attachment.file_location}")
end
else
@file = @attachment.full_file_location
if @path != "/" && File.exists?(@file)
send_file(@file,
:filename => @attachment.file_name,
:type => @attachment.file_type,
:disposition => "inline"
)
end
end
end
|