Upload files in Amazon S3 with Paperclip and Rails 4

Ishank Gupta
Here is a clean approachto set the configuration of model to upload images in Amazon S3 server with paperclipin Ruby on Rails. We need following gems in out Gemfile
gem 'paperclip' gem 'aws-sdk'
In the config folder create a file called config/api_config.ymlwhere youset up yourbucket name, amazon access key and access secret in the file.
 development: amazon_bucket_name: demo-dev amazon_access_key: XXXXXXXXXXXXXXXXXXXX amazon_access_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx production: amazon_bucket_name: demo-prod amazon_access_key: XXXXXXXXXXXXXXXXXXXX amazon_access_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Our next step isto create a file called config/paperclip_options.yml, which will contain configurations of paperclip like styles, url, convert_options, etc
 common: &default_settings :access_key_id: <%= API_CONFIG['amazon_access_key'] %> :secret_access_key: <%= API_CONFIG['amazon_access_secret'] %> :bucket: <%= API_CONFIG['amazon_bucket_name']...
Read more