Skip to content
Browse files

if creating an s3 directory (bucket), one needs to pass in :location …

…as well as have the aws connection set to the correct region...
  • Loading branch information...
1 parent ceadcb9 commit bf28b55821120f5ce9232c82c953de867b2584b4 Adam Greene committed Jun 5, 2011
Showing with 11 additions and 4 deletions.
  1. +10 −1 lib/fog/storage/aws.rb
  2. +1 −3 lib/fog/storage/models/aws/directory.rb
View
11 lib/fog/storage/aws.rb
@@ -70,7 +70,16 @@ def url(params, expires)
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
View
4 lib/fog/storage/models/aws/directory.rb
@@ -86,9 +86,7 @@ def save
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

0 comments on commit bf28b55

Please sign in to comment.
Something went wrong with that request. Please try again.