“S3 Bucket” is Amazon Simple Storage Service – a “highly durable and available store” and can be used to reliably store graphical and other applications contents such as media files, static assets and user uploads. It allows you to off-load your entire storage infrastructure. This feature facilitates better scalability, reliability, and speed than just storing files on the file-system.

It is an online storage web service offered by Amazon Web Services and provides storage through web services interfaces (REST, SOAP etc.)

Here is an example on how to use Amazon S3 with paperclip in Ruby on Rails applications.


  • In rails 3.x

Install aws-s3 gem by adding in Gemfile

gem 'aws-s3'

And run

Run “bundle install”


To get AWS S3 bucket ‘Access Key ID’ and ‘Secret Access Key’ go to the “”

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

bucket: bucket-dev-name
access_key_id: xxxxx
secret_access_key: xxxxx
bucket: bucket-test-name
access_key_id: xxxxx
secret_access_key: xxxxx
bucket: bucket-prod-name
access_key_id: xxxxx
secret_access_key: xxxxx


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

has_attached_file :photo,:styles =>{ :thumb => "100x100", :medium => "200x200", :large => "600x400" },:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",:path => ":attachment/:id/:style.:extension",:bucket => 'yourbucket'


In view, to display the image