我遇到了与AWS S3连接的问题,无法在StackO上找到答案。我在application.yml中对Aws_Access密钥/密码进行了三次检查。我想我正确地复制/粘贴它。 我是否需要在某处包含要求YAML?也许有复制/粘贴过程的问题,我真的,对我来说有点新鲜。
这是我的代码:
user.rb
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
config = YAML::load_file('config/application.yml')
has_attached_file :avatar,
:styles => {
:medium => "300x300>",
:thumb => "100x100#"
},
:default_url => "/images/:style/missing.png",
:url => ":s3_domain_url",
:path => "public/avatars/:id/:style_:basename.:extension",
:storage => :fog,
# Configuration for Amazon S3
:fog_credentials => {
provider: 'AWS',
region: 'us-west-2',
path_style: true,
aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"]
},
fog_directory: ENV["FOG_DIRECTORY"]
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
end
错误:
预期(200)&lt; =&gt;实际(403 Forbidden)excon.error.response:body =&gt; “\ N
SignatureDoesNotMatch
的 我们计算的请求签名与您的签名不符 提供。检查您的密钥和签名方法。 ....
SECRET_KEY_BASE: XXXXXXX
AWS_ACCESS_KEY_ID: AKXXXXXXBPQ
AWS_SECRET_ACCESS_KEY: yXXXXXXXXggj/KXXfXXXXXzJob
EMAIL_LOGIN: xxx@gmail.com
EMAIL_PASSWORD: xxxxx
development:
FOG_DIRECTORY: demo-dev
production:
FOG_DIRECTORY: demo-production
感谢您的帮助;)