简体   繁体   中英

Rails + Paperclip + S3 on Heroku upload error

I'm trying to build an app where users can upload a profile picture. I'm trying to use Paperclip and S3.

I've got it working on my local machine, but for some reason it doesn't work on Heroku. Specifically, nothing is getting uploaded to S3, but there are also no errors being produced in the Heroku logs from Paperclip or S3. Here's what I'm seeing in the logs:

2012-10-02T07:22:33+00:00 app[web.1]: [paperclip] Saving attachments.
2012-10-02T07:22:33+00:00 app[web.1]: [paperclip] saving profile_pictures/2/original.jpg
2012-10-02T07:22:33+00:00 app[web.1]: [paperclip] saving profile_pictures/2/thumb.jpg
2012-10-02T07:22:33+00:00 app[web.1]: [paperclip] saving profile_pictures/2/medium.jpg
2012-10-02T07:22:33+00:00 app[web.1]: [paperclip] saving profile_pictures/2/large.jpg

Here's what my s3.yml file looks like:

development:  
  access_key_id: XXXXXXX
  secret_access_key: XXXXXXX
  bucket: dev-bucket

test:
  access_key_id: XXXXXXX
  secret_access_key: XXXXXXX
  bucket: test-bucket

production:
  access_key_id: XXXXXXX
  secret_access_key: XXXXXXX
  bucket: prod-bucket

Anyone have an idea why this works on my dev machine but not on Heroku? I'm perplexed by the lack of an error...

Did you set the environment variables using Heroku Toolbelt?

$ heroku config:set AWS_BUCKET=**BUCKET NAME**
$ heroku config:set AWS_ACCESS_KEY_ID=***GET FROM AMAZON AWS***
$ heroku config:set AWS_SECRET_ACCESS_KEY=***GET FROM AMAZON AWS***

For this to work you would have to set:

config.paperclip_defaults = {
  :storage => :s3,
  :s3_credentials => {
    :bucket => ENV['AWS_BUCKET'],
    :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
    :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM