我有一个层次结构
my container
--images
--img01
--img02
我想发出休息请求并得到结果:<BlobPrefix>images</BlobPrefix>
如此链接所示https://learn.microsoft.com/en-us/rest/api/storageservices/fileservices/enumerating-blob-resources在“分隔 Blob 列表”部分下
但是,我没有得到这个结果,而是以递归调用的形式获取所有资源名称。就好像我没有提供任何分隔符一样。
要签名的字符串是:
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>
最佳答案
根据你的描述,我查了Delimited Blob List并在我这边测试了这个方法。为了简化这个问题,我创建了一个容器并将“容器公共(public)访问级别”设置为“容器和 blob 的公共(public)读取访问权限”。这是我的 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
结果:
根据您的stringToSign
,delimeter
的名称不正确,您需要将其更改为delimiter
。更多详情,您可以引用List Blobs .
关于rest - 我想使用 azure storage api 列出容器内的所有子文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42082638/