5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/protected_media_controller.rb', line 5
def show
@media = SpudMedia.where(:id => params[:id]).first
if @media.blank?
raise Spud::NotFoundError.new(:item => 'media')
else
if Spud::Media.config.paperclip_storage == :s3
secure_url = @media.attachment.s3_object(params[:style]).url_for(:read, :secure => true, :expires => 10.minutes)
redirect_to(secure_url.to_s)
else
filepath = @media.attachment.path(params[:style])
if !File.exists?(filepath)
raise Spud::NotFoundError.new(:item => 'media')
else
send_file(filepath, :disposition => 'inline')
end
end
end
end
|