Issues

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

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

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;