RAILS - FOG - 我们计算的请求签名与您提供的签名不符

时间:2016-08-09 09:30:07

标签: ruby-on-rails amazon-web-services amazon-s3 fog

我遇到了与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

感谢您的帮助;)

0 个答案:

没有答案