Issues

ZF-11114: Zend_Cloud_StorageService_Adapter_S3 method copyItem not implemented

Issue Type: Bug Created: 2011-02-25T08:06:59.000+0000 Last Updated: 2012-05-05T02:08:19.000+0000 Status: Resolved Fix version(s): - 1.11.12 (22/Jun/12)

  • 1.12.0 (27/Aug/12)

Reporter: Ondrej Hlavacek (ohlavacek) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Cloud_StorageService

  • state:need-feedback
  • zf-caretaker-adamlundrigan
  • zf-crteam-needsexpert
  • zf-crteam-padraic
  • zf-crteam-priority

Related issues: Attachments:

Description

The code if copyItem metod does not work at all. If needed, I can submit the correct implementation - it should be very easy, only forward the call to $this->_s3->copyObject method.

copyObject method could also be used as a workaround for storeMetadata.

Comments

Posted by Adam Lundrigan (adamlundrigan) on 2011-11-08T18:14:02.000+0000

The issue here appears to be that Zend_Cloud_StorageService_Adapter_S3::copyItem does fetch+store operations instead of using the available method Zend_Service_Amazon_S3::copyObject to signal Amazon S3 to perform the copy. There is a TODO to this effect in the code:

<pre class="highlight">
        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);
        } catch (Zend_Service_Amazon_S3_Exception  $e) {
            throw new Zend_Cloud_StorageService_Exception('Error on copy: '.$e->getMessage(), $e->getCode(), $e);
        }

@[~matthew], [~zimuel]: Is this on the development radar for ZFv1's Zend_Cloud? Is it as simple as the OP suggests (just call $this->_s3->copyObject(...))?

Posted by Adam Lundrigan (adamlundrigan) on 2012-02-24T00:07:48.000+0000

Here is a patch implementing the change:

<pre class="highlight">

Index: library/Zend/Cloud/StorageService/Adapter/S3.php
===================================================================
--- library/Zend/Cloud/StorageService/Adapter/S3.php    (revision 24628)
+++ library/Zend/Cloud/StorageService/Adapter/S3.php    (working copy)
@@ -177,9 +177,14 @@
     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);
         }

Posted by Adam Lundrigan (adamlundrigan) on 2012-05-05T02:03:25.000+0000

Fixed in trunk (1.12.0): r24752 Fixed in release-1.11 (1.11.12): r24753

Posted by Adam Lundrigan (adamlundrigan) on 2012-05-05T02:08:19.000+0000

ZF2 PR: https://github.com/zendframework/zf2/pull/1141

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts