0

I am trying to upload images to s3 but i am facing this error "Missing required arguments: aws_access_key_id, aws_secret_access_key"

class MyModel < ActiveRecord::Base

has_attached_file :attachment,
  :storage => :fog,
  :fog_credentials => {:provider => "AWS",
                       access_key_id: 'key_id',secret_access_key: 'access_key'},
  :fog_directory => 'bucket_name'

end
Bloomberg
  • 2,317
  • 2
  • 25
  • 47

1 Answers1

1

Use aws_access_key_id and aws_secret_access_key options in fog_credentials instead of access_key_id and secret_access_key.

has_attached_file :attachment,
  :storage => :fog,
  :fog_credentials => {:provider => "AWS",
                       aws_access_key_id: 'key_id',aws_secret_access_key: 'access_key'},
  :fog_directory => 'bucket_name'

Refer to the list of fog_credentials options

Kirti Thorat
  • 52,578
  • 9
  • 101
  • 108
  • in my image url i am getting my desktop path as well.. "https://com.bucket.name.s3.amazonaws.com//home/abhishek/Desktop/punchh-server/public176/Barbecue.png?1395418033 – Bloomberg Mar 21 '14 at 16:09
  • Glad to help.:) My answer resolves your current question. You can't access the image is another question. I would suggest you to post a separate question related to that. You can take a look at `:path` and `:url` options of `has_attached_file` that will resolve your issue. – Kirti Thorat Mar 21 '14 at 16:22