Blog
Posts tagged with "europe".
Setting a european endpoint in the aws-s3 gem
Mark
13 Sep 2011 10:31
We’re using paperclip to store files to S3 on a rails 3 project.
Our buckets are in europe and the s3 gem default sets the host to the US.
Here’s a quick initializer to override and set to use a european host (or one of your choosing).
Code from ella with minor adjustments:
https://github.com/marcel/aws-s3/issues/4
aws_s3_europe.rb
module AWS
module S3
ENDPOINTS = {
:us => 's3-us-west-1.amazonaws.com',
:asia => 's3-ap-southeast-1.amazonaws.com',
:europe => 's3-eu-west-1.amazonaws.com'
}
class Base
class << self
def 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
end
end
end
AWS::S3::Base.region = :europe

