initializer / aws.rb
keys = Rails.application.credentials[:aws]
creds = Aws::Credentials.new(keys[:access_key_id], keys[:secret_access_key])
Aws.config.update({
service: "s3",
region: 'eu-west-2',
credentials: creds
})
当我在控制器中执行此操作时,我会收到错误消息
s3 = Aws::S3::Client.new(
region: Aws.config[:region],
credentials: Aws.config[:credentials]
)
#ArgumentError (invalid configuration option `:service'):
我使用IAM凭据
ruby-sdk-3
好,我从service
中删除了Aws.config
,它可以正常工作,但是最好将此参数存储在config中
答案 0 :(得分:0)
s3 = Aws::Client.new(
region: Aws.config[:region],
credentials: Aws.config[:credentials]
)
尝试一下!
希望这对您有帮助!