public function delete(sfImagePoolCrop $crop = null)
 {
     parent::delete($crop);
     // Then deal with stuff on the edge - delete crop from edge
     if ($crop) {
         $resizer_options = array('width' => $crop->width, 'height' => $crop->height, 'scale' => !$crop->is_crop);
         $object_name = $this->getCloudName($resizer_options);
         try {
             $this->container->delete_object($object_name);
         } catch (NoSuchObjectException $e) {
             // Image already deleted from cloud - that's ok
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Test CDN connection
  *
  * @param string $error
  * @return boolean
  */
 function test(&$error)
 {
     if (!parent::test($error)) {
         return false;
     }
     if (!$this->_init($error) || !$this->_init_container($error)) {
         return false;
     }
     $string = 'test_rscf_' . md5(time());
     try {
         $object = $this->_container->create_object($string);
         $object->content_type = 'text/plain';
         $object->write($string, strlen($string));
     } catch (Exception $exception) {
         $error = sprintf('Unable to write object (%s).', $exception->getMessage());
         return false;
     }
     try {
         $object = $this->_container->get_object($string);
         $data = $object->read();
     } catch (Exception $exception) {
         $error = sprintf('Unable to read object (%s).', $exception->getMessage());
         try {
             $this->_container->delete_object($string);
         } catch (Exception $exception) {
         }
         return false;
     }
     if ($data != $string) {
         $error = 'Objects are not equal.';
         try {
             $this->_container->delete_object($string);
         } catch (Exception $exception) {
         }
         return false;
     }
     try {
         $this->_container->delete_object($string);
     } catch (Exception $exception) {
         $error = sprintf('Unable to delete object (%s).', $exception->getMessage());
         return false;
     }
     return true;
 }
 /**
  * @param \CF_Container $container
  */
 function it_should_not_mask_exception_when_delete($container)
 {
     $container->delete_object('filename')->willThrow(new \RuntimeException('delete'));
     $this->shouldThrow(new \RuntimeException('delete'))->duringDelete('filename');
 }
Ejemplo n.º 4
0
 /**
  * Delete a remote storage Object
  *
  * Given an Object instance or name, permanently remove the remote Object
  * and all associated metadata.
  *
  * Example:
  * <code>
  * # ... authentication code excluded (see previous examples) ...
  * #
  * $conn = new CF_Connection($auth);
  *
  * $images = $conn->get_container("my photos");
  *
  * # Delete specific object
  * #
  * $images->delete_object("disco_dancing.jpg");
  * </code>
  *
  * @param obj $obj name or instance of Object to delete
  * @param obj $container name or instance of Container in which the object resides (optional)
  * @return boolean <kbd>True</kbd> if successfully removed
  * @throws SyntaxException invalid Object name
  * @throws NoSuchObjectException remote Object does not exist
  * @throws InvalidResponseException unexpected response
  */
 function delete_object($obj, $container = NULL)
 {
     $this->initContainer();
     return parent::delete_object($obj, $container);
 }