亚马逊AWS S3客户端错误AWS-SDK红宝石

时间:2018-06-21 18:36:12

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

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中

1 个答案:

答案 0 :(得分:0)

s3 = Aws::Client.new(
  region: Aws.config[:region],
  credentials: Aws.config[:credentials]
)

尝试一下!

AWS Ruby-sdk

希望这对您有帮助!