Issues

ZF-11373: Amazon S3 putObject returns FALSE on any error instead of the status message which is ignored.

Issue Type: Improvement Created: 2011-05-13T16:52:49.000+0000 Last Updated: 2011-05-13T16:59:22.000+0000 Status: Open Fix version(s): Reporter: ken easson (keasson) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Service_Amazon

Related issues: Attachments:

Description

When Amazon S3 service returns error or some other network error occurs which is handled lower down, the service returns false without any additional information to help the calling service deal with the error.

Comments

Posted by ken easson (keasson) on 2011-05-13T16:59:22.000+0000

I have no idea how to upload a patch: since it's small. It's posted below.

--- library/Zend/Service/Amazon/S3.php (revision 24034) +++ library/Zend/Service/Amazon/S3.php (working copy) @@ -411,6 +411,7 @@

     $response = $this->_makeRequest('PUT', $object, null, $headers, $data);
  • // Check the MD5 Etag returned by S3 against and MD5 of the buffer if ($response->getStatus() == 200) { // It is escaped by double quotes for some reason @@ -418,7 +419,26 @@
         if (is_resource($data) || $etag == md5($data)) {
             return true;
  • } else { + /** + * @see Zend_Service_Amazon_S3_Exception + */ + require_once 'Zend/Service/Amazon/S3/Exception.php'; + throw new Zend_Service_Amazon_S3_Exception('MD5 Etag returned by S3 does not match MD5 of the buffer');
    } + } elseif ($response->getStatus() > 0) { + // throw an error with the server responce status + /** + * @see Zend_Service_Amazon_S3_Exception + */ + require_once 'Zend/Service/Amazon/S3/Exception.php'; + throw new Zend_Service_Amazon_S3_Exception('Amazon returned an error: ' . $response->getStatus() . '.'); + } else { + /** + * @see Zend_Service_Amazon_S3_Exception + */ + require_once 'Zend/Service/Amazon/S3/Exception.php'; + throw new Zend_Service_Amazon_S3_Exception('Unknown error putting object to S3'); }
     return false;

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