Exemple #1
0
 public function testGetObjects()
 {
     $objects = $this->rackspace->getObjects(TESTS_ZEND_SERVICE_RACKSPACE_CONTAINER_NAME);
     $this->assertTrue($objects !== false);
     $this->assertEquals($objects[0]->getName(), TESTS_ZEND_SERVICE_RACKSPACE_OBJECT_NAME);
     $this->assertEquals($objects[1]->getName(), TESTS_ZEND_SERVICE_RACKSPACE_OBJECT_NAME . '-copy');
 }
 /**
  * Tears down this test case
  *
  * @return void
  */
 public function tearDown()
 {
     if (!$this->_config) {
         return;
     }
     // Delete the container here
     $rackspace = new RackspaceService($this->_config->get(\Zend\Cloud\StorageService\Adapter\Rackspace::USER), $this->_config->get(\Zend\Cloud\StorageService\Adapter\Rackspace::API_KEY));
     $files = $rackspace->getObjects($this->_config->get(\Zend\Cloud\StorageService\Adapter\Rackspace::REMOTE_CONTAINER));
     if ($files == !false) {
         foreach ($files as $file) {
             $rackspace->deleteObject($this->_config->get(\Zend\Cloud\StorageService\Adapter\Rackspace::REMOTE_CONTAINER), $file->getName());
         }
     }
     $rackspace->deleteContainer($this->_config->get(\Zend\Cloud\StorageService\Adapter\Rackspace::REMOTE_CONTAINER));
     parent::tearDown();
 }
Exemple #3
0
 /**
  * Return an array of the items contained in the given path.  The items
  * returned are the files or objects that in the specified path.
  *
  * @param  string $path
  * @param  array  $options
  * @return array
  */
 public function listItems($path, $options = null)
 {
     if (!empty($path)) {
         $options = array('prefix' => $path);
     }
     $files = $this->rackspace->getObjects($this->container, $options);
     if (!$this->rackspace->isSuccessful()) {
         throw new Exception\RuntimeException('Error on list items: ' . $this->rackspace->getErrorMsg());
     }
     $resultArray = array();
     if (!empty($files)) {
         foreach ($files as $file) {
             $resultArray[] = $file->getName();
         }
     }
     return $resultArray;
 }
Exemple #4
0
 /**
  * Get all the object of the container
  *
  * @return Zend\Service\Rackspace\Files\ObjectList
  */
 public function getObjects()
 {
     return $this->service->getObjects($this->getName());
 }