无法在欧盟地区创建s3存储桶

无法在欧盟地区创建s3存储桶

问题描述:

body = "<CreateBucketConfiguration><LocationConstraint>EU</LocationConstraint></CreateBucketConfiguration>" 

     content_length = body.bytesize 
     content_type = "text/plain" 

     url = URI.parse("http://#{@name}.s3.amazonaws.com/") 

     req = Net::HTTP::Put.new(url.path) 
     req.body = body 
     req.add_field 'Date' , @time 
     req.add_field 'Host', "#{@name}.s3.amazonaws.com" 
     req.add_field 'Content-Type', "#{content_type}" 
     req.add_field 'Authorization', "#{signature}" 
     req.add_field 'Content-Length', "#{content_length}" 

     response = Net::HTTP.new(url.host, url.port).start do |http| 
      http.request(req) 
     end 

     puts response.read_body 

返回200并创建存储桶,但在美国标准中,而不在欧盟地区。我在这里错过了什么?谢谢您的帮助。无法在欧盟地区创建s3存储桶


这里是整个对话

PUT/HTTP/1.1  
Accept: */*  
User-Agent: Ruby  
Date: Wed, 19 Jan 2011 22:14:31 -0800  
Host: mytest.s3.amazonaws.com  
Content-Type: text/plain  
Authorization: AWS AC8RVKAXAU8Q:41uTqvfncc2mE561YabgpGUouio=  

Content-Length: 146 

<CreateBucketConfiguration xmlns='http://s3.amazonaws.com/doc/2006-03-01/'> 
    <LocationConstraint>EU</LocationConstraint> 
</CreateBucketConfiguration> 

HTTP/1.1 200 OK  
x-amz-id-2: lrlPt8Y19ZxFXPbZf9Gf6dYxTGLYkkMzo0tSNXCNk29o9xghcob502mcttQ/oo4W  
x-amz-request-id: 3504CCA0E7AFFE95  
Date: Thu, 20 Jan 2011 06:14:32 GMT  
Location: /mytest  
Content-Length: 0  
Server: AmazonS3 

HTTP/1.1 400 Bad Request  
Transfer-Encoding: chunked  
Date: Thu, 20 Jan 2011 06:14:32 GMT  
Connection: close  
Server: AmazonS3 

0 
+0

为什么不使用雾宝石做到这一点。这真的很好,你可以在 – shingara 2011-01-19 11:23:08

+0

里面定义你的s3区域为什么不安装http sniffer并查看发送给s3的是什么 – 2011-01-19 20:50:07

,我可以看到的唯一的事情是,你还没有包括在请求主体的xmlns - 不知道这将使任何区别,但。

xmlns="http://s3.amazonaws.com/doc/2006-03-01/"

body = "<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LocationConstraint>EU</LocationConstraint></CreateBucketConfiguration>"