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

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

Download a file inside a Shared Team Folder using the Python SDK

I'm trying to download files inside a shared Dropbox Team Folder.

 

I have a list of shared folders in my account and I have the preview URLs saved for all the folders.

Using the preview URLs, I am able to recursively get a list of all files within the directory as follows:

 

link = dropbox.files.SharedLink(url=shared)
entries = dbx.files_list_folder(path="", shared_link=link).entries

This works great - it gives me the list of all the files and folders inside. I can recursively run the files_list_folder with the updated path including the entry name as well. However, the path_lower values for all entries are None.

 

 

Next, I need to be able to download the files to my local machine using the SDK.

 

I can use the following for files in my personal/user dropbox account:

dbx.files_download_to_file(tmp, entry.id)

But I'm not able to use that to download files in the shared directry.

 

Instead of entry.id, I tried {path/to/file} and {parent folder id}/{path/to/file} but those doesn't work either.

I also tried using sharing_get_shared_link_file but that returns:

dropbox.exceptions.ApiError: ApiError('489644ba039f4389a501a619df93a11a', GetSharedLinkFileError('shared_link_not_found', None))

Any help would be greatly appreciated!! Thank you so much!

  • I can't say for sure exactly what's happening without seeing the actual values, but if the files are in the connected account, it's better to use paths/IDs everywhere, instead of preview/shared links. That's the more direct way of referencing things and may avoid the missing path values you mentioned, depending on the scenario.

     

    Also, note that if the files are in the "team space", you do need to set some additional configuration to be able to access them. (API calls operate in the "team member folder" by default, but you can access the "team space" when you need to.) I recommend reading the Team Files Guide first:

     

    https://www.dropbox.com/lp/developers/reference/dbx-team-files-guide

     

    In the Python SDK in particular, you can set that 'Dropbox-API-Path-Root' header via Dropbox.with_path_root.

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

    I can't say for sure exactly what's happening without seeing the actual values, but if the files are in the connected account, it's better to use paths/IDs everywhere, instead of preview/shared links. That's the more direct way of referencing things and may avoid the missing path values you mentioned, depending on the scenario.

     

    Also, note that if the files are in the "team space", you do need to set some additional configuration to be able to access them. (API calls operate in the "team member folder" by default, but you can access the "team space" when you need to.) I recommend reading the Team Files Guide first:

     

    https://www.dropbox.com/lp/developers/reference/dbx-team-files-guide

     

    In the Python SDK in particular, you can set that 'Dropbox-API-Path-Root' header via Dropbox.with_path_root.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,883 PostsLatest Activity: 11 hours ago
326 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!