Actually, this is my homework, I tried to record the step for how I resolve this issue.
I had read some articles and tried many ways(include heroku official document),
but it didn't work.
So I tried to read amazon official document and did some settings myself. Finally,
it works fine.
following are my steps:
(I assume that your app have already run well on heroku)
first, add this gem to your gemfile:
Gemfile
bundke install
add aws.yml under config folder:
aws.yml
development:
access_key_id: your access key id
secret_access_key: your secret access key
production:
access_key_id: your access key id
secret_access_key: your secret access key
then restart your rails server(for local test)
model action:
photo.rb
has_attached_file :image, :styles => { :medium => "300x300>",
:small => "150x150",
:thumb => "100x100>" },
:storage => :s3,
:s3_protocol => 'http',
:s3_host_name => 'your host name',
:bucket => 'bucket name'
Done! Paperclip will save your images on amazon s3 automatically!