本文介绍了通过python API列出azure blob存储中的虚拟文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在阅读本教程,但我无法找到一种方法来列出容器下的所有(虚拟)文件夹而不获取所有文件.我在500个(虚拟)文件夹中有26K个文件.我只想获取文件夹列表,而不必等待几分钟即可获取包含整个文件列表的list_blobs
输出.有没有办法做到这一点?还是至少告诉list_blobs
不要比容器下方的n
深?
I was reading this tutorial but I cannot find a way to list all the (virtual) folder under a container without getting all the files. I have 26K files in 500 (virtual) folders. I just want to get the list of folder without having to wait few minutes to get the output of list_blobs
containing the entire file list. Is there a way to do that? or at least tell list_blobs
to not go deeper than n
levels below a container?
推荐答案
您可以尝试以下操作:
from azure.storage import BlobService
blob_service = BlobService(account_name='account-name', account_key='account-key')
bloblistingresult = blob_service.list_blobs(container_name='container-name', delimiter='/')
for i in bloblistingresult.prefixes:
print(i.name) #this will print the names of the virtual folders
SDK源代码参考:BlobService.list_blobs()
SKD源代码参考:BlobService. list_blobs().prefixes
这篇关于通过python API列出azure blob存储中的虚拟文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!