exerq
exerq

Reputation: 125

Rails Access Deined when uploading image on Heroku to Amazon s3 with paperclip

i try to upload image using amazon S3, but i have this error:

AWS::S3::Errors::AccessDenied (Access Denied)

i used paperclip configuration:

    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']
    }
  }

and i set a permission like this

enter image description here

thank you !

EDIT:

I created another bucket and it works, but now i have this error:

NoMethodError (undefined method `first' for nil:NilClass):

Upvotes: 2

Views: 178

Answers (1)

Chaitanya Yadav
Chaitanya Yadav

Reputation: 76

production.rb/development.rb

config.paperclip_defaults = {
    :storage => :s3,
    :s3_protocol => 'http',
    :s3_credentials => {
      :bucket => ENV['S3_BUCKET_NAME'],
      :access_key_id => ENV['AWS_ACCESS_KEY'],
      :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
    }
  }

While Creating a bucket Select region as US-Standard and use above config. Try this it worked for me.Hopefully would work for you too.

Upvotes: 1

Related Questions