【问题标题】:My credential were working previously for AWS s3 on Rails 5我的凭证以前在 Rails 5 上为 AWS s3 工作
【发布时间】:2017-06-20 19:30:32
【问题描述】:

这是我得到的 rails 错误:

Aws::S3::Errors::SignatureDoesNotMatch (The request signature we calculated does not match the signature you provided. Check your key and signing method.):

我看到的解决方案没有奏效。

这是我的articles.rb,环境变量在heroku生产服务器和本地开发机器上设置:

class Article < ApplicationRecord
  has_many :comments, dependent: :destroy
  validates :title, presence: true,
                length: { minimum: 5 }
  has_attached_file :attachment,
            :path => 'assets/:class/:attachment/:id/:style/:filename',
            :storage => :s3,
            :bucket => ENV['AWS_BUCKET'],
            :s3_bucket => ENV['AWS_BUCKET'],
            :s3_permissions => 'public-read-write',
            :s3_protocol => 'http',
            :s3_host_name => 'eu-central-1.amazonaws.com',
            :s3_host_alias => 'eu-central-1.amazonaws.com',
            :s3_region => ENV['AWS_REGION'],
            :s3_credentials => { :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
                                 :secret_access_key => ENV['AWS_SECRET_KEY_ID'],
                                 :endpoint => 'eu-central-1.amazonaws.com' }

  # Explicitly do not validate
  do_not_validate_attachment_file_type :attachment
  #validates_attachment :attachment, content_type: { content_type:    'application/x-java-archive'}, size: { in: 0..10.megabytes }
 end

【问题讨论】:

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


    【解决方案1】:

    我不明白为什么?但是我必须在回形针配置中添加:url =&gt; :s3_domain_url 才能使这个错误消失。而我的TypeError in ArticlesController#create 仍然无法工作......在我将 AWS s3 添加到我的 Rails 应用程序之前,它工作正常:不幸的是,在 heroku 生产环境中没有持久存储。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-13
      • 1970-01-01
      • 2023-03-12
      • 2020-06-12
      • 2020-02-26
      相关资源
      最近更新 更多