获取容器内子目录内的所有 blob

Get all the blobs inside sub directory inside container

所以我在将 blob 放入我的容器时遇到了问题 - 我能够成功地抓取容器内的所有 blob,但不能抓取容器中文件夹内的所有 blob - 我如何才能成功那个?

问题:
我的容器内有一个名为“big/”的文件夹 - 我如何才能从该文件夹中获取所有 blob 而不是像我在下面所做的那样只获取通用容器?

我们将不胜感激!

所以这是我的 getBlobs() 方法(查看下面的图像和代码):

/**
 * Get all blobs from container
 *
 * @param int $max
 * @return array
 */
public function getBlobs(int $max = 5000) : array
{
    // Check if a container is set
    if (!$this->containerName) {
        return [];
    }

    try {
        $blobMeta = [];
        $blobOptions = new ListBlobsOptions();

        // Set the max results at 5000 (Default: 5000)
        $blobOptions->setMaxResults($max);

        do {
            // Grab the defined container
            $blob_list = $this->connect()->listBlobs(
                $this->containerName,
                $blobOptions
            );

            var_dump($blob_list);
            die();

            // Loop through all the
            foreach ($blob_list->getBlobs() as $blob) {
                $blobMeta[] = [
                    'name' => $blob->getName(),
                    'url' => $blob->getUrl(),
                ];
            }
            $blobOptions->setContinuationToken($blob_list->getContinuationToken());

        } while ($blob_list->getContinuationToken());

        return $blobMeta;
    } catch (ServiceException $e) {
        $code = $e->getCode();
        $error_message = $e->getMessage();
        echo $code . ": " . $error_message . PHP_EOL;
        return [];
    }
}

如果要列出文件夹下的 blob,可以使用 ListBlobsOptionssetPrefix("YourFolderName/") 来执行此操作。您可以在 listBlobsSample 函数的第 430 行 here.

中找到详细的代码示例