Skip to content

Instantly share code, notes, and snippets.

View asn's full-sized avatar

Axel Sachmann asn

  • Cologne / Germany
View GitHub Profile
# 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')