Amazon S3 and Paperclip on Rails 3

First step Install aws-s3 by adding Gemfile

gem 'aws-s3'

Open your terminal and run

bundle install

Create s3.yml file under config directory and enter your Amazon S3 credentials.

access_key_id: '<< access_key_id >>'
secret_access_key: '<< secret_access_key >>'

Open your model file that will hold the attachment and modify it as follows:

  has_attached_file :image, 
    :styles => { :medium => "300x300>", :thumb => "100x100>" },
    :storage => :s3,
    :s3_credentials => "#{Rails.root}/config/s3.yml",
    :path => ":attachment/:id/:style/:basename.:extension",
    :bucket => '<< your bucket name >>'
Advertisements

About me
Interested about Ruby on Rails

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: