Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uninitialized constant AWS::S3::Base via AWS-SDK

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.

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'
like image 717
Keith Connolly Avatar asked Apr 13 '12 08:04

Keith Connolly


2 Answers

Yeah, aws-sdk doesn't have AWS::S3::Base. I think this is the closest equivalent:

s3 = AWS::S3.new(:access_key_id => '****', :secret_access_key => '***')
like image 52
rcrogers Avatar answered Sep 30 '22 04:09

rcrogers


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

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.

like image 24
Konstantino Sparakis Avatar answered Oct 01 '22 04:10

Konstantino Sparakis