簡體   English   中英

將 PDF 上傳到 Azure 數據湖存儲 Gen2

[英]Upload PDF to Azure Data Lake store Gen2

我無法使用 Python SDK 將 PDF 上傳到數據湖。 過去有人試過嗎?

請嘗試以下代碼:

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)

它對我有用。希望這可以幫助你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM