Преглед изворни кода

ZF-11114: Update Zend_Cloud_StorageService_Adapter_S3 to do a copy instead of fetch+store

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24752 44c647ce-9c0f-0410-b52a-842ac1e357ba
adamlundrigan пре 13 година
родитељ
комит
4f4d5d46d6
1 измењених фајлова са 8 додато и 3 уклоњено
  1. 8 3
      library/Zend/Cloud/StorageService/Adapter/S3.php

+ 8 - 3
library/Zend/Cloud/StorageService/Adapter/S3.php

@@ -177,9 +177,14 @@ class Zend_Cloud_StorageService_Adapter_S3
     public function copyItem($sourcePath, $destinationPath, $options = array())
     {
         try {
-            // TODO We *really* need to add support for object copying in the S3 adapter
-            $item = $this->fetch($_getFullPath(sourcePath), $options);
-            $this->storeItem($item, $destinationPath, $options);
+            $fullSourcePath = $this->_getFullPath($sourcePath, $options);
+            $fullDestPath   = $this->_getFullPath($destinationPath, $options);
+            return $this->_s3->copyObject(
+                $fullSourcePath,
+                $fullDestPath,
+                empty($options[self::METADATA]) ? null : $options[self::METADATA]
+            );
+
         } catch (Zend_Service_Amazon_S3_Exception  $e) {
             throw new Zend_Cloud_StorageService_Exception('Error on copy: '.$e->getMessage(), $e->getCode(), $e);
         }