AWS::Errors::MissingCredentialsError using paperclip and aws-s3 in rails 3.1

后端 未结 1 746
南旧
南旧 2021-01-14 03:42

I am trying to upload image at aws.

class Asset < ActiveRecord::Base
  belongs_to :post
  attr_accessible :image
  has_attached_file :image, :styles =>         


        
相关标签:
1条回答
  • 2021-01-14 04:21

    The following worked for me:

    1. Create a file in your initializers called aws.rb
    2. Put in the following in your aws.rb file:

      AWS.config(
      access_key_id: 'your_access_key',
      secret_access_key: 'your_secret_access_key')
      
    3. Then my paperclip options looks like this:

      has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>" },       
      :default_url => "missing_:style.png", :default_url => 'missing_:style.png', :storage =>   
      :s3, :bucket => "<my_bucket>"
      
    0 讨论(0)
提交回复
热议问题