container)) { $configOptions = [ 'authUrl' => Config::get("cloudstorage.auth_url"), 'region' => Config::get("cloudstorage.region"), ]; $userName = Config::get("cloudstorage.user_name"); $userPassword = Config::get("cloudstorage.api_key"); if(!empty($userName) && !empty($userPassword)){ $configOptions['user'] = [ 'name' => $userName, 'password' => $userPassword, 'domain' => ['id' => Config::get("cloudstorage.user_domain", "default")] ]; $configOptions['scope' ] = [ 'project' => [ 'name' => Config::get("cloudstorage.project_name"), 'domain' => ['id' => Config::get("cloudstorage.project_domain", "default")] ], ]; } $appCredentialId = Config::get("cloudstorage.app_credential_id"); $appCredentialSecret = Config::get("cloudstorage.app_credential_secret"); if(!empty($appCredentialId) && !empty($appCredentialSecret)){ $configOptions['application_credential'] = [ 'id' => $appCredentialId, 'secret' => $appCredentialSecret, ]; } $openstack = new OpenStack($configOptions); $this->container = $openstack->objectStoreV1()->getContainer( Config::get("cloudstorage.assets_container")); } return $this->container; } /** * @param File $f * @param string $local_path * @return object|StorageObject * @throws Exception */ public function put(File $f, $local_path) { $fp = fopen($local_path, 'r'); if (!$fp) { throw new Exception("Unable to open file: " . $f->getFilename()); } $options = [ 'name' => $f->getRelativeLinkFor(), 'stream' => new Stream($fp) ]; return $this->getContainer()->createObject($options); } }