public function opendir($path) { $path = $this->normalizePath($path); if ($path === '.') { $path = ''; } else { $path .= '/'; } $path = str_replace('%23', '#', $path); // the prefix is sent as a query param, so revert the encoding of # try { $files = array(); /** @var OpenCloud\Common\Collection $objects */ $objects = $this->container->objectList(array('prefix' => $path, 'delimiter' => '/')); /** @var OpenCloud\ObjectStore\Resource\DataObject $object */ foreach ($objects as $object) { $file = basename($object->getName()); if ($file !== basename($path)) { $files[] = $file; } } \OC\Files\Stream\Dir::register('swift' . $path, $files); return opendir('fakedir://swift' . $path); } catch (\Exception $e) { \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); return false; } }
/** * Create a collection of files to be migrated and add them to the read queue */ protected function enqueueGetRequests() { $files = $this->oldContainer->objectList(array('limit.total' => false, 'limit.page' => $this->options->get('read.pageLimit'))); foreach ($files as $file) { $this->readQueue->add($this->getClient()->get($file->getUrl())); } }
/** * Get a file's metadata * * @param string $path * @return array file metadata */ public function listContents($directory = '', $recursive = false) { $response = $this->container->objectList(array('prefix' => $directory)); $response = iterator_to_array($response); $contents = array_map(array($this, 'normalizeObject'), $response); return Util::emulateDirectories($contents); }
/** * {@inheritdoc} */ public function listContents($directory = '', $recursive = false) { $location = $this->applyPathPrefix($directory); $response = $this->container->objectList(['prefix' => $location]); $response = iterator_to_array($response); $contents = array_map([$this, 'normalizeObject'], $response); return Util::emulateDirectories($contents); }
/** * {@inheritdoc} */ public function listContents($directory = '', $recursive = false) { $response = []; $marker = null; $location = $this->applyPathPrefix($directory); while (true) { $objectList = $this->container->objectList(['prefix' => $location, 'marker' => $marker]); if ($objectList->count() === 0) { break; } $response = array_merge($response, iterator_to_array($objectList)); $marker = end($response)->getName(); } return Util::emulateDirectories(array_map([$this, 'normalizeObject'], $response)); }
/** * Deletes the file * * @param string $key * * @return boolean */ public function delete($key) { if (!($object = $this->tryGetObject($key))) { return false; } try { if ($this->isDirectory($key)) { $objects = $this->container->objectList(['prefix' => $key]); foreach ($objects as $object) { $object->delete(); } } else { $object->delete(); } } catch (DeleteError $deleteError) { return false; } return true; }