Created
September 23, 2009 12:01
-
-
Save ledermann/191937 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Building authenticated and expiring URL for S3 | |
# Based on | |
# http://github.com/logandk/paperclip_hacks/blob/master/lib/paperclip.rb | |
# and | |
# http://thewebfellas.com/blog/2009/8/29/protecting-your-paperclip-downloads | |
module Paperclip | |
class Attachment | |
def authenticated_url(style = nil, expires_in = 5.minutes) | |
if @storage.to_s == 's3' && file? | |
AWS::S3::S3Object.url_for(path(style || default_style), bucket_name, :expires_in => expires_in, :use_ssl => s3_protocol == 'https') | |
else | |
url | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice ! thx for this gist