【问题标题】:Azure FileProperties content missing on list_directories_and_fileslist_directories_and_files 上缺少 Azure FileProperties 内容
【发布时间】:2018-07-23 14:08:30
【问题描述】:

我正在使用 Django 2.0.4、Python 3.5 和 Azure FileStorage:

Azure Python API

Seems to work with Blobs

使用 Azure Python 包一切正常。现在我想列出一个目录的所有文件并查看它们的LastModified 属性和其他一些属性:

# getting Azure service
azureService = getAzureService()

# list all files in directory
archivesList = azureService.list_directories_and_files('myfilestoragename', directory_name='archives')
for element in archivesList:
    element_name = element.name
    element_lastmodified = element.properties.last_modified
    element_contentlength = element.properties.content_length

问题是:element_lastmodified 总是None 但是element_contentlength 具有有效值。

当我使用 MS Azure 存储资源管理器并查看每个文件的 properties 时,LastModified 属性具有有效的时间戳。

有什么想法吗?谢谢!

【问题讨论】:

    标签: python azure-storage azure-files


    【解决方案1】:

    last_modified 始终为 None,因为不幸的是,服务在列出目录和文件时不会返回此信息。请参考 REST 文档here

    要获取文件/目录的最后修改时间,请使用get_directory_properties和get_file_properties。

    【讨论】:

    • 感谢您的参考!所以我必须为列表中的每个文件使用get_file_properties - 哇,python api 文档中没有引用。获取这些信息的选项会很好......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-05
    • 2021-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多