فهرست منبع

ZF-6728: createBucket() now support the location according with the PUT syntax of Amazon S3 API

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24049 44c647ce-9c0f-0410-b52a-842ac1e357ba
ezimuel 14 سال پیش
والد
کامیت
5f8e47a107
2فایلهای تغییر یافته به همراه10 افزوده شده و 5 حذف شده
  1. 4 2
      library/Zend/Service/Amazon/S3.php
  2. 6 3
      tests/Zend/Service/Amazon/S3/OnlineTest.php

+ 4 - 2
library/Zend/Service/Amazon/S3.php

@@ -157,14 +157,16 @@ class Zend_Service_Amazon_S3 extends Zend_Service_Amazon_Abstract
     public function createBucket($bucket, $location = null)
     {
         $this->_validBucketName($bucket);
-
+        $headers=array();
         if($location) {
             $data = '<CreateBucketConfiguration><LocationConstraint>'.$location.'</LocationConstraint></CreateBucketConfiguration>';
+            $headers['Content-type']= 'text/plain';
+            $headers['Contne-size']= strlen($data);
         }
         else {
             $data = null;
         }
-        $response = $this->_makeRequest('PUT', $bucket, null, array(), $data);
+        $response = $this->_makeRequest('PUT', $bucket, null, $headers, $data);
 
         return ($response->getStatus() == 200);
     }

+ 6 - 3
tests/Zend/Service/Amazon/S3/OnlineTest.php

@@ -71,6 +71,7 @@ class Zend_Service_Amazon_S3_OnlineTest extends PHPUnit_Framework_TestCase
         $this->_httpClientAdapterSocket = new Zend_Http_Client_Adapter_Socket();
 
         $this->_bucket = constant('TESTS_ZEND_SERVICE_AMAZON_S3_BUCKET');
+        $this->_bucketEu = $this->_bucket.'-EU';
 
         $this->_amazon->getHttpClient()
                       ->setAdapter($this->_httpClientAdapterSocket);
@@ -395,10 +396,10 @@ class Zend_Service_Amazon_S3_OnlineTest extends PHPUnit_Framework_TestCase
      */
     public function testCreateBucketEU()
     {
-        $this->_amazon->createBucket($this->_bucket, 'EU');
-        $this->assertTrue($this->_amazon->isBucketAvailable($this->_bucket));
+        $this->_amazon->createBucket($this->_bucketEu, 'EU');
+        $this->assertTrue($this->_amazon->isBucketAvailable($this->_bucketEu));
         $list = $this->_amazon->getBuckets();
-        $this->assertContains($this->_bucket, $list);
+        $this->assertContains($this->_bucketEu, $list);
     }
     /**
      * Test bucket name with /'s and encoding
@@ -488,6 +489,8 @@ class Zend_Service_Amazon_S3_OnlineTest extends PHPUnit_Framework_TestCase
         unset($this->_amazon->debug);
         $this->_amazon->cleanBucket($this->_bucket);
         $this->_amazon->removeBucket($this->_bucket);
+        $this->_amazon->cleanBucket($this->_bucketEu);
+        $this->_amazon->removeBucket($this->_bucketEu);
     }
 }