我想使用azure storage api列出容器内的所有子文件夹

时间:2017-02-07 05:49:47

标签: rest azure azure-storage azure-storage-blobs

我有一个层次结构

my container
  --images
      --img01
      --img02

我想提出休息请求并获得结果:<BlobPrefix>images</BlobPrefix>

如此链接https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/enumerating-blob-resources所示,&#34;分隔的Blob列表&#34;

但是,我没有得到这个结果而不是我将所有资源名称作为递归调用。好像我没有提供任何分隔符。

要签名的字符串是:

GET /account/mycontainer

x-ms-date:Tue, 07 Feb 2017 05:38:21 GMT
x-ms-version:2016-05-31
comp:list
delimeter:/
maxresults:4
restype:container

我发送的网址:

http://account.blob.core.windows.net/mycontainer?restype=container&comp=list&delimeter=/&maxresults=4

结果我得到了:

<xml>
<blobs>
<blob><Name>images/img01</Name>
<blob><Name>images/img02</Name>
</blobs>
</xml>

但是基于上面提到的链接。答案应该是:

<xml>
<blobs>
<BlobPrefix>
<Name>images/</Name>
</BlobPrefix >
</xml>

1 个答案:

答案 0 :(得分:5)

根据你的描述,我检查了Delimited Blob List,并在我身边测试了这种方法。为简化此问题,我创建了一个容器,并将“Container Public Access Level”设置为“容器和blob的公共读取访问权限”。这是我的blob容器的文件结构:

  • 列出blob而未指定分隔符(默认为“/”)

https://brucechen.blob.core.windows.net/brucechen?restype=container&comp=list

<强>结果:

  • 通过指定分隔符(默认为“/”)
  • 来列出blob

https://brucechen.blob.core.windows.net/brucechen?restype=container&comp=list&delimiter=%2F

<强>结果:

根据您的stringToSigndelimeter的名称不正确,您需要将其更改为delimiter。有关详细信息,请参阅List Blobs