【问题标题】:Upload PDF to Azure Data Lake store Gen2将 PDF 上传到 Azure Data Lake Store Gen2
【发布时间】:2020-07-26 06:51:41
【问题描述】:

我无法使用 Python SDK 将 PDF 上传到 Data Lake。过去有人尝试过吗?

【问题讨论】:

  • 到目前为止你尝试了什么?请在您的问题中添加一些代码...

标签: azure azure-data-lake


【解决方案1】:

请尝试以下代码:

try:
    client = DataLakeServiceClient.from_connection_string(conn_str=my_connection_string)
    file_system_client = client.get_file_system_client(file_system_name)
    directory_client = file_system_client.get_directory_client(file_name)
    file_client = directory_client.create_file("test.pdf")
    f = open(local_path,'rb')
    file_contents = f.read()
    file_client.upload_data(file_contents, overwrite=True)
    f.close()
except Exception as e:
    print(e)

它对我有用。希望这可以帮助你。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-02
    • 1970-01-01
    • 1970-01-01
    • 2019-07-10
    • 2020-02-22
    • 2021-03-06
    • 2019-11-13
    • 1970-01-01
    相关资源
    最近更新 更多