Esempio n. 1
0
 private function initialize()
 {
     if (!$this->container instanceof Container) {
         if ($this->createContainer) {
             $container = $this->objectStore->Container();
             $container->name = $this->containerName;
             $container->Create();
         } else {
             $container = $this->objectStore->Container($this->containerName);
         }
         $this->container = $container;
     }
 }
Esempio n. 2
0
 public function __construct($params)
 {
     if (!isset($params['key']) and !isset($params['password']) or !isset($params['user']) or !isset($params['bucket']) or !isset($params['region'])) {
         throw new \Exception("API Key or password, Username, Bucket and Region have to be configured.");
     }
     $this->id = 'swift::' . $params['user'] . md5($params['bucket']);
     $this->bucket = $params['bucket'];
     if (!isset($params['url'])) {
         $params['url'] = 'https://identity.api.rackspacecloud.com/v2.0/';
     }
     if (!isset($params['service_name'])) {
         $params['service_name'] = 'cloudFiles';
     }
     $settings = array('username' => $params['user']);
     if (isset($params['password'])) {
         $settings['password'] = $params['password'];
     } else {
         if (isset($params['key'])) {
             $settings['apiKey'] = $params['key'];
         }
     }
     if (isset($params['tenant'])) {
         $settings['tenantName'] = $params['tenant'];
     }
     $this->anchor = new \OpenCloud\OpenStack($params['url'], $settings);
     if (isset($params['timeout'])) {
         $this->anchor->setHttpTimeout($params['timeout']);
     }
     $this->connection = $this->anchor->ObjectStore($params['service_name'], $params['region'], 'publicURL');
     try {
         $this->container = $this->connection->Container($this->bucket);
     } catch (Exceptions\ContainerNotFoundError $e) {
         $this->container = $this->connection->Container();
         $this->container->Create(array('name' => $this->bucket));
     }
     if (!$this->file_exists('.')) {
         $this->mkdir('.');
     }
 }