【问题标题】:Load files to Azure file storage using python使用 python 将文件加载到 Azure 文件存储
【发布时间】:2019-09-23 05:29:58
【问题描述】:

我正在使用 azure 文件存储来实现多个容器实例的数据持久性,在这方面,它工作正常。我遇到的问题是,一些容器读取了我通过 Web 界面手动加载到文件存储的数据。我需要更新它才能从 python 加载文件,但我没有找到任何关于如何做到这一点的示例。

有一个来自 Azure https://github.com/Azure/azure-storage-python 的 github 存储库应该可以处理这个问题,但我在那里没有找到任何示例,只有源代码。在 medium 和其他网站上,我找到了使用 Blob 的教程,但我没有找到任何关于文件的教程

【问题讨论】:

标签: python azure storage


【解决方案1】:

正如评论所说,samples 显示文件共享的操作。我假设您想从文件共享中的文件中读取内容,以下代码相同:

from azure.storage.file import FileService

storageAccount='xxxxx'
accountKey='xxxxx'

file_service = FileService(account_name=storageAccount, account_key=accountKey)

# if the file in the root path of the share, please let the directory name as ''
file = file_service.get_file_to_text(share_name, directory_name, file_name)
print(file.content)

此代码获取类型为File 的文件。

【讨论】:

    猜你喜欢
    • 2019-05-15
    • 2021-06-20
    • 2017-08-18
    • 2019-12-01
    • 2023-03-31
    • 2022-10-15
    • 2017-08-05
    • 2020-05-12
    • 1970-01-01
    相关资源
    最近更新 更多