DollarChills
DollarChills

Reputation: 1086

Permission denied Paperclip and s3 error

I have a rails 4 app deployed on heroku. I'm using Amazon s3 bucket to host images (using paperclip gem), but when I try to upload an image to my articles controller i get this error:

Permission denied @ dir_s_mkdir - /articles

I have gone through the steps listed here. As i understand this could be a folder permission issue, but not really to sure how to tackle the issue.

Upvotes: 1

Views: 644

Answers (1)

user3361996
user3361996

Reputation: 373

Try putting the following code in your /config/environments/production.rb file and update ENV secret key names accordingly. The host name is dependent on your region, us-west-1, eu-west-1, etc.

config.paperclip_defaults = {
    :storage => :s3,
    :s3_credentials => {
      :bucket => ENV['S3_BUCKET_NAME'],
      :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
      :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
      :s3_host_name => 's3-us-west-1.amazonaws.com'
    }
}

Upvotes: 3

Related Questions