Skip to content

Instantly share code, notes, and snippets.

@lokimeyburg
Created October 29, 2012 18:36
Show Gist options
  • Save lokimeyburg/3975584 to your computer and use it in GitHub Desktop.
Save lokimeyburg/3975584 to your computer and use it in GitHub Desktop.
Paperclip & Amazon S3
# environments/{development.rb || test.rb}
# Left blank to skip s3 in development.
PAPERCLIP_STORAGE_OPTIONS = {}
# models/picture.rb
has_attached_file :attachment, { :styles => { :thumbnail => "x80>" },
:url => "/system/attachments/:hash.:extension", :hash_secret => "UMdHdTJhPZqoD1ffOWv" }.merge(PAPERCLIP_STORAGE_OPTIONS)
# environments/production.rb
PAPERCLIP_STORAGE_OPTIONS = { :storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => ":attachment/:id/:style/:basename.:extension"
}
# /config/s3.yml
development:
access_key_id: access_key_id_goes_here
secret_access_key: secret/access_key_goes_here
bucket: dev_bucket_name_goes_here
production:
access_key_id: access_key_id_goes_here
secret_access_key: secret/access_key_goes_here
bucket: bucket_name_goes_here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment