2013-06-20 141 views
1

使用aws-s3创业板,我可以用标准s3存储桶成功执行交易,但在爱尔兰(s3-eu-west-1)制造的存在错误The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.经过2个小时的搜索后,仍然意味着什么对我来说,是否有办法解决这个问题。访问非标准S3存储桶

This simple tutorial适用于标准S3铲斗,但不适用于爱尔兰。

person's experiences似乎暗示这是不可能的。

回答

6

好的我刚刚找到了the answer here

require 'aws/s3' 
AWS::S3::Base.establish_connection!(
    :access_key_id  => ACCESS_KEY_ID, 
    :secret_access_key => SECRET_ACCESS_KEY 
) 
AWS::S3::DEFAULT_HOST.replace('s3-eu-west-1.amazonaws.com') # <= the crucial hacky line 
AWS::S3::S3Object.store(
    file_name, 
    temp_file, 
    bucket, 
    :content_type => mime_type 
) 

编辑

Much better option是使用aws-sdk宝石,其API似乎要好很多,例如:

require 'aws-sdk' 
s3 = AWS::S3.new(
    :access_key_id => ACCESS_KEY_ID, 
    :secret_access_key => SECRET_ACCESS_KEY, 
    :s3_endpoint => 's3-eu-west-1.amazonaws.com' 
) 
bucket = s3.buckets[bucket_name] 
bucket.objects.create(
    file_name, 
    temp_file, 
    :content_type => mime_type 
)