Skip to content

Instantly share code, notes, and snippets.

@tomlea
Created January 20, 2010 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tomlea/281541 to your computer and use it in GitHub Desktop.
Save tomlea/281541 to your computer and use it in GitHub Desktop.
# A secure S3 storage engine for Paperclip.
# Usage:
#
# require "paperclip/storage/s3secure"
# has_attached_file :image, :storage => :S3secure, …
module Paperclip::Storage::S3secure
def self.extended base
base.extend(Paperclip::Storage::S3)
base.options[:s3_permissions] = :private
end
def url(style = default_style, include_updated_timestamp = false)
s3_options = {:expires_in => 10.minutes}
AWS::S3::S3Object.url_for path(style), options[:bucket], s3_options
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment