Przeglądaj źródła

ZF-6717: Add support for putting the bucket name in the end point (myawesomebucket.s3.amazonaws.com) for better support with the eu instances.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15649 44c647ce-9c0f-0410-b52a-842ac1e357ba
sidhighwind 16 lat temu
rodzic
commit
2643d67020
1 zmienionych plików z 15 dodań i 6 usunięć
  1. 15 6
      library/Zend/Service/Amazon/S3.php

+ 15 - 6
library/Zend/Service/Amazon/S3.php

@@ -48,7 +48,7 @@ class Zend_Service_Amazon_S3 extends Zend_Service_Amazon_Abstract
      */
     protected static $_wrapperClients = array();
 
-    const S3_ENDPOINT = 'http://s3.amazonaws.com';
+    const S3_ENDPOINT = 's3.amazonaws.com';
 
     const S3_ACL_PRIVATE = 'private';
     const S3_ACL_PUBLIC_READ = 'public-read';
@@ -246,14 +246,14 @@ class Zend_Service_Amazon_S3 extends Zend_Service_Amazon_Abstract
             require_once 'Zend/Service/Amazon/S3/Exception.php';
             throw new Zend_Service_Amazon_S3_Exception("Bucket name contains invalid characters");
         }
-        
+
         if(empty($nameparts[1])) {
             return $object;
         }
-        
+
         return $nameparts[0].'/'.urlencode($nameparts[1]);
     }
-    
+
     /**
      * Get an object
      *
@@ -386,7 +386,16 @@ class Zend_Service_Amazon_S3 extends Zend_Service_Amazon_Abstract
                                   'Expect'      => null,
                                   'Range'       => null,
                                   'x-amz-acl'   => null));
-        $client->setUri(self::S3_ENDPOINT.'/'.$path);
+
+        // build the end point out
+        $parts = explode('/', $path);
+        if(count($parts) > 1) {
+            $endpoint = 'http://' . $parts[0] . '.' . self::S3_ENDPOINT;
+            array_shift($parts);
+            $client->setUri($endpoint . '/' . implode('/', $parts));
+        } else {
+            $client->setUri('http://' . self::S3_ENDPOINT.'/'.$path);
+        }
         $client->setHeaders($headers);
 
         if (is_array($params)) {
@@ -430,7 +439,7 @@ class Zend_Service_Amazon_S3 extends Zend_Service_Amazon_Abstract
      * Add the S3 Authorization signature to the request headers
      *
      * @param  string $method
-     * @param  string $path
+     * @param  string $pathhttp://
      * @param  array &$headers
      * @return string
      */