You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

ankg's avatar
ankg
New member | Level 2
5 years ago

databricks pyspark/ python download data from shared url and password

Hi,

 

I have received a dropbox shared secure link and password which I want to connect to my databricks environment so that I can download the files from dropbox to my databricks environment. 

Appreciate if someone can share an example code to do that. I have a dropbox url and password. 

Thanks!

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    We can't offer help on the Databricks/Pyspark side of this, as that's made by a third party, but to programmatically download file data from a password-protected Dropbox shared link, we recommend using the official Dropbox API v2 Python SDK. Specifically, you can use the sharing_get_shared_link_file method to download file data from a shared link, optionally supplying the password if needed.

    That would look like this:

    import dropbox
    
    ACCESS_TOKEN = "..."
    
    dbx = dropbox.Dropbox(ACCESS_TOKEN)
    
    shared_link = "https://www.dropbox.com/s/..."
    password = "..."
    
    metadata, res = dbx.sharing_get_shared_link_file(url=shared_link, link_password=password)
    print(metadata)
    print(res.text)

    The second variable in the returned tuple is a requests.Response object, which offers a few methods for reading out the file content.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,889 PostsLatest Activity: 8 hours ago
327 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!