2011-01-19 1 views
0
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 

renvoie 200 et crée un compartiment mais en U.S Standard et non en UE. Qu'est-ce que j'oublie ici? Merci pour l'aide.Impossible de créer un compartiment s3 dans la région de l'UE


Voici la conversation

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

Pourquoi ne pas utiliser la pierre précieuse de brouillard pour le faire. C'est vraiment génial et vous pouvez définir votre région s3 à l'intérieur – shingara

+0

pourquoi ne pas installer http sniffer et voir ce qui était vraiment envoyé à s3 –

+0

J'ai inclus la conversation – user290870

Répondre

0

La seule chose que je peux voir est que vous n'avez pas inclus le xmlns dans le corps de la demande - ne sais pas si cela fera une différence bien.

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

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

J'ai inclus les xmlns mais crée toujours des seaux en US Standard seulement. – user290870

+0

@ user290870: Avez-vous déjà créé le compartiment mytest au standard américain? Les noms de compartiment doivent être globalement uniques (par exemple, parmi ** tous ** les utilisateurs de S3) –

+0

Je crée un nouveau compartiment avec un nom globalement unique. – user290870

Questions connexes