/** * {@inheritdoc} */ public function getObjectByContainer(OpenCloudContainer $container, array $objectData) { $object = $container->dataObject(); $object->setName($objectData['name']); if (isset($objectData['content_type'])) { $object->setContentType($objectData['content_type']); } return $object; }
/** * Create a tailored PUT request for each file * * @param Response $response * @return \Guzzle\Http\Message\EntityEnclosingRequestInterface */ protected function createPutRequest(Response $response) { $segments = Url::factory($response->getEffectiveUrl())->getPathSegments(); $name = end($segments); // Retrieve content and metadata $file = $this->newContainer->dataObject()->setName($name); $file->setMetadata($response->getHeaders(), true); return $this->getClient()->put($file->getUrl(), $file::stockHeaders($file->getMetadata()->toArray()), $response->getBody()); }
public function unlink($path) { $path = $this->normalizePath($path); if ($this->is_dir($path)) { return $this->rmdir($path); } try { $this->container->dataObject()->setName($path)->delete(); } catch (ClientErrorResponseException $e) { \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); return false; } return true; }
/** * @param string $urn Unified Resource Name * @return void * @throws Exception from openstack lib when something goes wrong */ public function deleteObject($urn) { $this->init(); // see https://github.com/rackspace/php-opencloud/issues/243#issuecomment-30032242 $this->container->dataObject()->setName($urn)->delete(); }