Created
September 16, 2010 21:24
-
-
Save elia/583198 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws/s3' | |
class << AWS::S3 | |
# The 3 S3 enpoints (http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RequestEndpoints.html). | |
ENDPOINTS = { | |
:us => 's3-us-west-1.amazonaws.com', | |
:asia => 's3-ap-southeast-1.amazonaws.com', | |
:europe => 's3-eu-west-1.amazonaws.com' | |
} | |
# Set the region and automatically adjust the endpoint of reference. | |
# Example: | |
# AWS::S3::Base.region = :europe | |
# | |
def Base.region= region | |
endpoint = ENDPOINTS[region] or | |
raise S3Exception, "Unknown region: please use one of #{ENDPOINTS.keys.map(&:inspect).join(', ')}." | |
DEFAULT_HOST.replace endpoint | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment