【问题标题】:AWS::S3::SignatureDoesNotMatch with aws-s3 in railsAWS::S3::SignatureDoesNotMatch 与导轨中的 aws-s3
【发布时间】:2011-10-23 01:29:55
【问题描述】:

我正在尝试将数据上传到 amazon s3 存储桶。 为此,我正在使用 aws-s3 gem。 我提供了正确的访问密钥和安全密钥,但仍然无法执行 S3Object.store/Bucket 调用,尽管连接已建立。他们返回错误“AWS::S3::SignatureDoesNotMatch:我们计算的请求签名与您提供的签名不匹配。请检查您的密钥和签名方法。”

有趣的是,我正在运行另一个带有回形针插件的 rails 应用程序来将图像上传到 S3,这就像一个魅力!具有相同的访问密钥和安全密钥。

我尝试引用一些提到相同问题的链接,但没有成功。 [https://forums.aws.amazon.com/thread.jspa?threadID=16020&tstart=0]

任何指针/帮助/建议都会很棒。 :)

【问题讨论】:

    标签: ruby-on-rails-3 rubygems amazon-s3 paperclip


    【解决方案1】:

    我刚刚遇到了这个问题,因为我没有在请求中提供正确的区域。

    我根据 railscast here 使用 fogCarrierwave,我必须在配置/初始化程序中为 Carrierwave 配置区域

    CarrierWave.configure do |config|
      config.fog_credentials = {
        provider:              'AWS',                        # required
        aws_access_key_id:     '[redacted]',       # required unless using use_iam_profile
        aws_secret_access_key: '[redacted]', # required unless using use_iam_profile
        # use_iam_profile:       false,                         # optional, defaults to false
        region:                'eu-central-1',                  # optional, defaults to 'us-east-1'
        # host:                  's3.example.com',             # optional, defaults to nil
        # endpoint:              'https://s3.example.com:8080' # optional, defaults to nil
      }
      config.fog_directory  = 'xxx'                                      # required
      # config.fog_public     = false                                                 # optional, defaults to true
      # config.fog_attributes = { cache_control: "public, max-age=#{365.days.to_i}" } # optional, defaults to {}
    end
    

    有趣的是,amazon 将雾重定向到具有正确区域的正确端点,但是,重定向的请求在身份验证时失败,在这种情况下可能是雾的问题。雾确实在日志中给出了一个很好的警告

    [fog][WARNING] fog: followed redirect to calm4-files.s3.amazonaws.com, connecting to the matching region will be more performant

    但为了更准确,他们应该说not only more performant, but it will actually work as well

    【讨论】:

      猜你喜欢
      • 2020-02-24
      • 2012-05-02
      • 1970-01-01
      • 1970-01-01
      • 2017-09-06
      • 2016-11-02
      • 1970-01-01
      • 1970-01-01
      • 2015-09-05
      相关资源
      最近更新 更多