这是我得到的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
答案 0 :(得分:0)
我不明白为什么?但我不得不在回形针配置中添加:url => :s3_domain_url
以使此错误消失。我的TypeError in ArticlesController#create
仍然无效...在我将AWS s3添加到我的Rails应用程序之前,它运行正常:不幸的是在heroku生产环境中没有持久存储。