I'm receiving the following error:
The AWS Access Key Id you provided does not exist in our records.
I'm not sure why I would be getting this error because I have the correct access key and secret key shown to me in my aws security credentials page (I have copied and pasted multiple times to refute the possibility of a typo). Why would it be telling me that my access key is not in their records if I am able to log in and visit my STILL empty buckets?
Here is my s3.yml:
GMAIL_USERNAME: <my email>
GMAIL_PASSWORD: <my password>
MONGOHQ_URL: <my mongoid url>
S3_BUCKET_NAME_DEVELOPMENT: <my development bucket>
S3_BUCKET_NAME_PRODUCTION: <my production bucket>
S3_BUCKET_NAME_TEST: <my test bucket>
AWS_ACCESS_KEY_ID: <my access key>
AWS_SECRET_ACCESS_KEY: <my secret key>
Here is my picture.rb:
class Picture
include Mongoid::Document
include Mongoid::Paperclip
embedded_in :datum, inverse_of: :pictures
has_mongoid_attached_file :attachment,
path: ':attachment/:id/:style.:extension',
storage: :s3,
url: ':s3_domain_url',
bucket: Proc.new{ |a| a.instance.s3_bucket },
s3_credentials: File.join(Rails.root, 'config', 's3.yml'),
styles: {
original: ['1920x1680', :jpg],
small: ['100x100', :jpg],
medium: ['250x250', :jpg],
large: ['500x500', :jpg]
},
convert_options: { all: '-background white -flatten +matte' }
def s3_bucket
if Rails.env.development?
ENV['S3_BUCKET_NAME_DEVELOPMENT']
else
ENV['S3_BUCKET_NAME_PRODUCTION']
end
end
end
Here is my datum.rb:
class Datum
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paperclip
field :title, type: String
field :user_id, type: Integer
validates :title, presence: true
validates :user_id, presence: true
embeds_many :todo_items
embeds_many :pictures, cascade_callbacks: true
accepts_nested_attributes_for :pictures
end
Here is my datum_params
method:
# Never trust parameters from the scary internet, only allow the white list through.
def datum_params
params.require(:datum).permit(:title, :user_id, :identifying_image, pictures_attributes: [:picture])
end
Here is my picture_params
method:
def picture_params
params.require(:picture).permit(:datum_id, :attachment)
end
Here is the form I use for the upload:
<%= bootstrap_form_for(picture, url: { action: :create }, html: { multipart: true }, remote: true ) do |f| %>
<%= f.file_field :picture, multiple: true, name: 'picture[picture]' %>
<%= f.submit 'Upload' %>
<% end %>
Originally, I was having a strong_parameters issue that rails4guides.com (the user with the answer below) was able to help me overcome. I knew I made progress when I stopped getting an unpermitted parameter error and started getting errors from AWS. Can anyone see any reason why my credentials are not working? Am I supposed to be seeing anything about my access key in the request parameters? Because I don't at this time.