From bf28b55821120f5ce9232c82c953de867b2584b4 Mon Sep 17 00:00:00 2001 From: Adam Greene Date: Sun, 5 Jun 2011 19:37:50 -0700 Subject: [PATCH] if creating an s3 directory (bucket), one needs to pass in :location as well as have the aws connection set to the correct region... --- lib/fog/storage/aws.rb | 11 ++++++++++- lib/fog/storage/models/aws/directory.rb | 4 +--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/fog/storage/aws.rb b/lib/fog/storage/aws.rb index 012e99f93..1a548fbc2 100644 --- a/lib/fog/storage/aws.rb +++ b/lib/fog/storage/aws.rb @@ -70,7 +70,16 @@ module Fog query << "Expires=#{params[:headers]['Date']}" "https://#{@host}/#{params[:path]}?#{query.join('&')}" end - + + def host + @host + end + + def region + region = @region || host.split('.').first.gsub(/s3-?/, '') + region.empty? ? 'us-east-1' : region + end + end class Mock diff --git a/lib/fog/storage/models/aws/directory.rb b/lib/fog/storage/models/aws/directory.rb index 902cb4ae5..d35f0a59a 100644 --- a/lib/fog/storage/models/aws/directory.rb +++ b/lib/fog/storage/models/aws/directory.rb @@ -86,9 +86,7 @@ module Fog if @acl options['x-amz-acl'] = @acl end - if @location - options['LocationConstraint'] = @location - end + options['LocationConstraint'] = @location || self.connection.region connection.put_bucket(key, options) true end