Skip to content

Instantly share code, notes, and snippets.

@elia
Created September 16, 2010 21:24
Show Gist options
  • Save elia/583198 to your computer and use it in GitHub Desktop.
Save elia/583198 to your computer and use it in GitHub Desktop.
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