This is an issue I'm having with the fact that after I upgraded to AWS-SDK (instead of aws-s3) with the newer version(s) of paperclip I can no longer call AWS::S3::Base.establish_connection! at all.
这是我遇到的一个问题,在我使用更新版的回形针升级到AWS-SDK(而不是aws-s3)后,我再也无法调用AWS :: S3 :: Base.establish_connection了!一点都不
Where ever in my code I call
在我的代码中,我打电话
AWS::S3::Base.establish_connection!(:access_key_id => '****', :secret_access_key => '***')
I get this error...
我收到这个错误......
NameError (uninitialized constant AWS::S3::Base):
app/models/asset.rb:28:in `move_upload_from_temp_to_final_resting_place'
3 个解决方案
#1
21
Yeah, aws-sdk doesn't have AWS::S3::Base
. I think this is the closest equivalent:
是的,aws-sdk没有AWS :: S3 :: Base。我认为这是最接近的等价物:
s3 = AWS::S3.new(:access_key_id => '****', :secret_access_key => '***')
#2
2
As this was the first page that popped up for me on my google search to solve this issue I will comment on how I managed to solve it. Under the AWS SDK 2.0.47
由于这是我在谷歌搜索中为我解决此问题而弹出的第一页,我将评论我是如何设法解决它的。在AWS SDK 2.0.47下
require 'rubygems'
require 'aws/s3'
include AWS::S3
AWS::S3::Base.establish_connection!(
:access_key_id => '',
:secret_access_key => ''
)
I was simply missing the include AWS::S3. And I suspect many people are running into this issue as I have yet to see a straight foward answer.
我只是错过了包含AWS :: S3。我怀疑很多人都在讨论这个问题,因为我还没有看到直接的回答。
#3
0
I tried Konstantino solution but, unfortunately, it didn't work for me. using include AWS::S3
threw the following exception.
我试过Konstantino解决方案,但不幸的是,它对我不起作用。使用include AWS :: S3引发了以下异常。
TypeError: wrong argument type Class (expected Module)
TypeError:错误的参数类型Class(预期的模块)
This is how I solved the same issue
这就是我解决同样问题的方法
AWS.send(:remove_const, :S3) if AWS::S3.class == Class
require Gem::Specification.find_by_name("aws-s3").gem_dir + "/lib/aws/s3.rb"
as I was using aws-s3
's modules and methods in another method that was initiated using delayed_job
, this patch didn't create issue in my case. But this can create issues in another use case as aws-sdk
's class is now replaced with aws-s3
's module.
因为我在另一个使用delayed_job启动的方法中使用aws-s3的模块和方法,这个补丁在我的情况下没有产生问题。但这可能会在另一个用例中产生问题,因为aws-sdk的类现在已被aws-s3的模块替换。
#1
21
Yeah, aws-sdk doesn't have AWS::S3::Base
. I think this is the closest equivalent:
是的,aws-sdk没有AWS :: S3 :: Base。我认为这是最接近的等价物:
s3 = AWS::S3.new(:access_key_id => '****', :secret_access_key => '***')
#2
2
As this was the first page that popped up for me on my google search to solve this issue I will comment on how I managed to solve it. Under the AWS SDK 2.0.47
由于这是我在谷歌搜索中为我解决此问题而弹出的第一页,我将评论我是如何设法解决它的。在AWS SDK 2.0.47下
require 'rubygems'
require 'aws/s3'
include AWS::S3
AWS::S3::Base.establish_connection!(
:access_key_id => '',
:secret_access_key => ''
)
I was simply missing the include AWS::S3. And I suspect many people are running into this issue as I have yet to see a straight foward answer.
我只是错过了包含AWS :: S3。我怀疑很多人都在讨论这个问题,因为我还没有看到直接的回答。
#3
0
I tried Konstantino solution but, unfortunately, it didn't work for me. using include AWS::S3
threw the following exception.
我试过Konstantino解决方案,但不幸的是,它对我不起作用。使用include AWS :: S3引发了以下异常。
TypeError: wrong argument type Class (expected Module)
TypeError:错误的参数类型Class(预期的模块)
This is how I solved the same issue
这就是我解决同样问题的方法
AWS.send(:remove_const, :S3) if AWS::S3.class == Class
require Gem::Specification.find_by_name("aws-s3").gem_dir + "/lib/aws/s3.rb"
as I was using aws-s3
's modules and methods in another method that was initiated using delayed_job
, this patch didn't create issue in my case. But this can create issues in another use case as aws-sdk
's class is now replaced with aws-s3
's module.
因为我在另一个使用delayed_job启动的方法中使用aws-s3的模块和方法,这个补丁在我的情况下没有产生问题。但这可能会在另一个用例中产生问题,因为aws-sdk的类现在已被aws-s3的模块替换。