Permalink
Browse files

Added clean support for AWS Europe

  • Loading branch information...
Vlad
Vlad committed Mar 1, 2009
1 parent ac97d47 commit a13504ba581496eab253583f38d26aa475949b53
Showing with 5 additions and 5 deletions.
  1. +2 −2 lib/aws/s3/authentication.rb
  2. +1 −1 lib/aws/s3/bucket.rb
  3. +1 −1 lib/aws/s3/connection.rb
  4. +1 −1 lib/aws/s3/object.rb
@@ -156,7 +156,7 @@ def initialize(request, options = {})
# "For non-authenticated or anonymous requests. A NotImplemented error result code will be returned if
# an authenticated (signed) request specifies a Host: header other than 's3.amazonaws.com'"
# (from http://docs.amazonwebservices.com/AmazonS3/2006-03-01/VirtualHosting.html)
request['Host'] = DEFAULT_HOST
request['Host'] = AWS::S3::Base.connection.subdomain || DEFAULT_HOST
build
end

@@ -173,7 +173,7 @@ def build
self << (key =~ self.class.amazon_header_prefix ? "#{key}:#{value}" : value)
self << "\n"
end
self << path
self << (AWS::S3::Base.connection.subdomain ? "/#{AWS::S3::Base.connection.subdomain}#{path}" : path)
end

def initialize_headers
@@ -178,7 +178,7 @@ def path(name, options = {})
options = name
name = nil
end
"/#{bucket_name(name)}#{RequestOptions.process(options).to_query_string}"
bucket_name(name) == connection.subdomain ? "/#{RequestOptions.process(options).to_query_string}" : "/#{bucket_name(name)}#{RequestOptions.process(options).to_query_string}"
end
end

@@ -69,7 +69,7 @@ def url_for(path, options = {})
end

def subdomain
http.address[/^([^.]+).#{DEFAULT_HOST}$/, 1]
http.address[/^(.+)\.#{DEFAULT_HOST}$/, 1]
end

def persistent?
@@ -297,7 +297,7 @@ def path!(bucket, name, options = {}) #:nodoc:
options.replace(bucket)
bucket = nil
end
'/' << File.join(bucket_name(bucket), name)
bucket_name(bucket) == connection.subdomain ? "/#{name}" : "/#{bucket_name(bucket)}/#{name}"
end

private

8 comments on commit a13504b

@khelal

This comment has been minimized.

Copy link

khelal replied Aug 12, 2009

Can somebody please write the test cases for this so that it can finally be merged into the production code?

@tejo

This comment has been minimized.

Copy link

tejo replied Jan 22, 2010

Actually this patch seems not to work....

@vladr

This comment has been minimized.

Copy link
Owner

vladr replied Jan 22, 2010

Make sure your amazon_s3.yml correctly specifies the bucket_name AND server:

production:
bucket_name: blabla
...
server: blabla.s3.amazonaws.com
...

@tejo

This comment has been minimized.

Copy link

tejo replied Jan 22, 2010

Hi vladr, thanks for your reply.

I use it in plain ruby, and I specify bucket name in ruby code:

require 'rubygems'
require 'aws/s3'
AWS::S3::Base.establish_connection!(
:access_key_id => 'my_key',
:secret_access_key => 'my_access'
)
pic = AWS::S3::S3Object.find 'my_file_name', 'my_bucket_name'

this code raise the famous AWS::S3::PermanentRedirect error

@vladr

This comment has been minimized.

Copy link
Owner

vladr replied Jan 22, 2010

You HAVE TO EXPLICITLY specify <your_bucket_here>.amazonws.com as the server (instead of the default, North-American server s3.amazonws.com). Thus, <your_bucket_here>.amazonws.com will resolve to the EU server if your bucket is in the EU. How do you expect anyone to guess that your bucket is on the EU as opposed to the NA servers?

@tejo

This comment has been minimized.

Copy link

tejo replied Jan 22, 2010

You are totally right. My bad.

Thanks

@vladr

This comment has been minimized.

Copy link
Owner

vladr replied Jan 22, 2010

Welcome :)

@jinixdme

This comment has been minimized.

Copy link

jinixdme replied Oct 22, 2010

I've added the patch to version 0.6.2, but it doesn't function. I'm still getting "The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint". Using the bucket name as subdomain didn't help (eg .s3.amazonaws.com or <bucket.s3-eu-west-1.amazonaws.com>).

What is the server for the EU? Is s3-eu-west-1 correct? I've uploaded a file via console and the file url was: https://s3-eu-west-1.amazonaws.com//

Uploading, renaming etc. to the (default) US server works fine w/ aws-s3.

Please sign in to comment.