我有以下脚本:
require 'httparty'
require 'aws-sdk-s3'
include HTTParty
Aws.config.update({
region: 'us-east-1',
credentials: Aws::Credentials.new('...', '...')
})
client = Aws::S3::Resource.new
movies = self.class.get("#{HOST}/movies")当我运行它时,会遇到以下错误:
Traceback (most recent call last):
10: from script.rb:33:in `<main>'
9: from script.rb:33:in `new'
8: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-athena-1.22.0/lib/aws-sdk-athena/resource.rb:14:in `initialize'
7: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:99:in `new'
6: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-athena-1.22.0/lib/aws-sdk-athena/client.rb:262:in `initialize'
5: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:19:in `initialize'
4: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:62:in `build_config'
3: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:149:in `build!'
2: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:158:in `empty_struct'
1: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:158:in `new'
/Users/me/.rvm/gems/ruby-2.6.5/gems/httparty-0.17.1/lib/httparty/module_inheritable_attributes.rb:42:in `inherited': undefined method `each' for nil:NilClass (NoMethodError)在阅读了AWS的文档和教程之后,我仍然找不到问题。有什么不对的?
发布于 2020-02-05 00:46:20
我发现问题是线include HTTParty。我在S3客户端之前声明了这一行,它现在起作用了:
require 'httparty'
require 'aws-sdk-s3'
Aws.config.update({
region: 'us-east-1',
credentials: Aws::Credentials.new('...', '...')
})
client = Aws::S3::Resource.new
include HTTParty
movies = self.class.get("#{HOST}/movies")https://stackoverflow.com/questions/60067552
复制相似问题