简体   繁体   English

将 PDF 上传到 Azure 数据湖存储 Gen2

[英]Upload PDF to Azure Data Lake store Gen2

I am unable to upload PDF to Data Lake, using Python SDK.我无法使用 Python SDK 将 PDF 上传到数据湖。 Did anyone try it in the past?.过去有人试过吗?

Please try the below code:请尝试以下代码:

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)

It works on my side.Hope this can help you.它对我有用。希望这可以帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 数据湖存储 Gen2 权限 - Azure Data Lake storage Gen2 permissions Azure 的“Data Lake Storage Gen2”和“Data Lake Gen2”有什么区别? - What is the difference between Azure's "Data Lake Storage Gen2" and "Data Lake Gen2"? 我们能否使用Azure CLI将文件上传到Azure Data Lake Storage Gen2 - Can we use Azure CLI to upload files to Azure Data Lake Storage Gen2 ML 组件在指向 Azure Data Lake Store Gen2 的 Azure Databricks (7.3.9) 中不起作用 - ML Components not working in Azure Databricks (7.3.9) pointing to Azure Data Lake Store Gen2 如何创建文件或将文件上传到Azure Data Lake Storage Gen2 - How to create a file or upload a file to Azure Data Lake Storage Gen2 如何将 .parquet 文件从本地计算机上传到 Azure Storage Data Lake Gen2? - How can I upload a .parquet file from my local machine to Azure Storage Data Lake Gen2? 使用 Azure CLI 将用户权限添加到 Data Lake Store Gen2 文件夹 - Add user rights to Data Lake Store Gen2 Folder with Azure CLI 找不到 Data Lake Store Gen2 - Can't Find Data Lake Store Gen2 Azure Data Lake Analytics 是否支持 ADLS Gen2? - Will Azure Data Lake Analytics support ADLS Gen2? 如何在Azure数据湖Gen2中处理遥测JSON消息? - How to process the telemetry json messages in Azure data lake Gen2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM