Best way to debug Fog/S3 connection?

800 views
Skip to first unread message

Marc

unread,
Mar 15, 2011, 2:26:46 PM3/15/11
to carrierwave
Hi all,

I'm trying to move from file storage to S3 (using the Fog-gem) and am
running into some problems. I have everything set up as documented in
the code, but whenever I try to upload a file it raises an error.
Looking at my logs it looks like Amazon is denying access (403), but I
can't figure out why. If I use the fog gem directly with the same
credentials everything works fine.

What's the best approach to tackle this problem? In my logs I can see
all the data that is being sent to S3 and what S3 is sending back, but
I can't make a lot of sense of it. The only thing that caught my eye
was that the Authorization-header started with "AWS " and then my
access key, instead of just my access key. Should it do that?

By the way, changing my credentials to something invalid raises the
same errors so it looks like the credentials are messed up somewhere
in the process.

Any help is appreciated.

Marc

Trevor Turk

unread,
Mar 16, 2011, 4:45:56 AM3/16/11
to carri...@googlegroups.com
On Tuesday, March 15, 2011 6:26:46 PM UTC, Mar c wrote:
I'm trying to move from file storage to S3 (using the Fog-gem) and am
running into some problems.

I basically sounds like your credentials are wrong. Are you using the latest Carrierwave from master? And the latest Fog gem? Then, take a look at the Carrierwave readme on Github and make sure you're passing in the right options. I know that it works first-hand, so really you must just be passing in the wrong credentials, or the correct credentials wrongly, if you know what I mean. 

If you can't figure it out, put a gist of the error you're getting here and your config -- removing your secret keys of course.  

Nic

unread,
Mar 25, 2011, 12:25:08 PM3/25/11
to carrierwave
I am having a similar problem, here is my code inside my uploader:

# Choose what kind of storage to use for this uploader:
storage :s3
# storage :fog

fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => 'XXXXXX', # required
:aws_secret_access_key => 'XXXX/XXXXX', # required
#:region => 'eu-west-1' # optional, defaults to
'us-east-1'
}
fog_directory = 'XXXXXX' # required
#fog_host = 'XXXXXXX' # optional, defaults to nil
fog_public = false # optional,
defaults to true
#fog_attributes = {'Cache-Control'=>'max-age=315576000'} #
optional, defaults to {}


When I try to create a new upload I get the error: "can't convert nil
into String" in my create action.

I tried setting the storage to :fog, but that just made it break right
away. The fog_directory I am using is relative from the top level of
the s3 bucket, is that right?

Thanks,
-Nic

Trevor Turk

unread,
Mar 26, 2011, 5:28:18 AM3/26/11
to carri...@googlegroups.com, Nic
On Friday, March 25, 2011 4:25:08 PM UTC, Nic wrote:
I am having a similar problem, here is my code inside my uploader

I think that you should take a moment to watch the Railscast, and maybe check out an example app or two. Here's one I made:


- Trevor

Nic

unread,
Mar 28, 2011, 1:05:04 PM3/28/11
to carrierwave
You have this code in your config/initializers/carrierwave:

CarrierWave.configure do |config|
config.root = Rails.root.join('tmp')
config.cache_dir = 'carrierwave'

config.s3_access_key_id = ENV['s3_access_key_id']
config.s3_secret_access_key = ENV['s3_secret_access_key']
config.s3_bucket = ENV['s3_bucket']
end

I haven't seen that in any documentation or examples (I see fog being
used). Could you tell me where the documentation for that is? Using
"s3" instead of "fog" is giving me the same error regardless.

And my main problem here is that I have multiple uploaders that do not
all upload to the same spot, so I can't do a global config.

-Nic

Nic

unread,
Mar 30, 2011, 11:53:35 AM3/30/11
to carrierwave
I figured it out, though I'm not exactly sure what was wrong. The
link to the 0.5.2 readme which was removed from the main git page
helped quite a bit for anyone who is having troubles in Rails 3:
https://github.com/jnicklas/carrierwave/tree/v0.5.2

Devis Battisti

unread,
Apr 26, 2011, 5:58:09 AM4/26/11
to carrierwave
try setting confing.fog_host .

Devis_
Reply all
Reply to author
Forward
0 new messages