2
votes

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):
1
Have you set your ENV vars in the Heroku config? - Richard Peck
Yes I set AWS configuration vars - exerq

1 Answers

1
votes

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.