简体   繁体   中英

Upload PDF to Azure Data Lake store Gen2

I am unable to upload PDF to Data Lake, using Python SDK. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM