/** * @inheritdoc */ public function listContents($directory = '', $recursive = false) { $options = new ListBlobsOptions(); $options->setPrefix($directory); /** @var ListBlobsResult $listResults */ $listResults = $this->client->listBlobs($this->container, $options); $contents = []; foreach ($listResults->getBlobs() as $blob) { $contents[] = $this->normalizeBlobProperties($blob->getName(), $blob->getProperties()); } return Util::emulateDirectories($contents); }
/** * {@inheritDoc} */ public function keys() { $this->init(); try { $blobList = $this->blobProxy->listBlobs($this->containerName); return array_map(function ($blob) { return $blob->getName(); }, $blobList->getBlobs()); } catch (ServiceException $e) { $this->failIfContainerNotFound($e, 'retrieve keys'); $errorCode = $this->getErrorCodeFromServiceException($e); throw new \RuntimeException(sprintf('Failed to list keys for the container "%s": %s (%s).', $this->containerName, $e->getErrorText(), $errorCode), $e->getCode()); } }
/** * {@inheritdoc} */ public function listContents($directory = '', $recursive = false) { $directory = $this->applyPathPrefix($directory); // Append trailing slash only for directory other than root (which after normalization is an empty string). // Listing for / doesn't work properly otherwise. if (strlen($directory)) { $directory = rtrim($directory, '/') . '/'; } $options = new ListBlobsOptions(); $options->setPrefix($directory); if (!$recursive) { $options->setDelimiter('/'); } /** @var ListBlobsResult $listResults */ $listResults = $this->client->listBlobs($this->container, $options); $contents = []; foreach ($listResults->getBlobs() as $blob) { $contents[] = $this->normalizeBlobProperties($blob->getName(), $blob->getProperties()); } if (!$recursive) { $contents = array_merge($contents, array_map([$this, 'normalizeBlobPrefix'], $listResults->getBlobPrefixes())); } return Util::emulateDirectories($contents); }