【发布时间】:2021-04-20 12:54:26
【问题描述】:
我使用 Django 和 django-storages[azure] 作为后端。 但我无法找出列出文件的目录,而是我必须像这样使用 sn-ps:
block_blob_service.list_blobs(container_name='media', prefix=folderPath)]
这不起作用:
listdir(absoluteFolderPath)
在 storages/backend/azure_storage.py 我找到了这部分:
def listdir(self, path=''):
"""
Return directories and files for a given path.
Leave the path empty to list the root.
Order of dirs and files is undefined.
"""
files = []
dirs = set()
for name in self.list_all(path):
n = name[len(path):]
if '/' in n:
dirs.add(n.split('/', 1)[0])
else:
files.append(n)
return list(dirs), files
但是我该如何使用它呢?
问候 克里斯托弗。
【问题讨论】:
标签: django azure-storage azure-blob-storage django-storage