We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
rk90
7 years agoHelpful | Level 5
How do I get all files and folders on Dropbox Business account
I have asked this question in the past and did get answers but I am still struggling to figure this out. Basically, I want to export the entire structure of the given Dropbox Business account to a l...
Greg-DB
Dropbox Community Moderator
7 years agoTeam folders are for sharing content with one's team. You can find more information on team folders in the help center here.
Shared folders can be used to share folders with arbitrary users. You can find more information on shared folders in the help center here.
rk90
7 years agoHelpful | Level 5
Whenever I think I have an idea about how I am going to get what I want, I bump into something that makes me wonder if I should really do this project.
I list namespaces and the namespace.name for team member folder is 'Root'. I list folders recursively and there are thousands of deleted files/folders that don't have 'path_display' attribute and I don't know how would I get the size of those deleted files/folders without knowing thier path or an identifier. Then there are several entries in folder list response that do not have 'path_display' attribute. All I see in those entries are ( {'name': '<item name>', 'parent_shared_folder_id': '<id>, 'id': 'id:<id>'} ). I don't know how am I supposed to construct the absolute path of such entries unless Dropbox expects us to make another request to another endpoint to get the absolute path of such entries.
I have seen poorly designed APIs, but Dropbox APIs are worst. I wonder if the developers knew what they were doing. Dropbox chose not to give an endpoint that can be queried to get the unique listing of all files/folders rather they chose to give something like impersonation where you impersonate each user or an admin and list the same folders and do the sorting yourself. No API to get the size of folder (list folders recursively and get calculate the size). The list goes on.
You guys forward feature requests but those get moved to the trash bin because Dropbox does not want to make things easy.
- Greg-DB7 years ago
Dropbox Community Moderator
Thanks for the feedback! We appreciate it. I'm sharing this with the team.
Note that if a Metadata object doesn't contain `path_lower` or `path_display`, it indicates that "the file or folder is not mounted". I.e., it's in a shared folder that isn't currently added to the account, so it doesn't have a path in the account.
And it sounds like specifically, you'd like the following, so I've enumerated the following feature requests for the team:
- The ability to easily get the total size for a folder's contents
- The ability to get the size for a deleted file
- rk907 years agoHelpful | Level 5
This is not true, there are several folders that are inside team folders and show up within the team folder on the UI, but when I list those folders via API I don't see `path_display`. Moreover, there are several deleted files/folders in the response that just have `name` but no `path_display` or `path_lower`.
Note that if a Metadata object doesn't contain `path_lower` or `path_display`, it indicates that "the file or folder is not mounted". I.e., it's in a shared folder that isn't currently added to the account, so it doesn't have a path in the account.
I am frustrated because of the disambiguity and unnecessary optional fields in the response. Most importantly if someone was given a task to generate the list of all files/folders on a given Dropbox account, it will take them forever because Dropbox doesn't have an endpoint that can be called to list each and every folder. What Dropbox expects us to do is call `list_folder/{continue}`. Consider 1000 members that have almost identical folders (i.e. a large shared folder shared with all of them). When I list each member's folder recursively I will be unneccesarily listing that same shared folder 1000 times. If I want to skip listing that folder again, then I need to set `recursive=False` and check each folder in response to see if it was listed previously, unnecssary processing. APIs are suppossed to make life easier not difficult.
- Greg-DB7 years ago
Dropbox Community Moderator
there are several folders that are inside team folders and show up within the team folder on the UI, but when I list those folders via API I don't see `path_display`
Do you mean you're calling for a namespace directly as an admin without a root like this?
curl -X POST https://api.dropboxapi.com/2/files/list_folder \ --header "Authorization: Bearer <ACCESS_TOKEN>" \ --header "Dropbox-API-Select-Admin: <ADMIN_USER_ID>" \ --header "Content-Type: application/json" \ --data "{\"path\": \"ns:1990893360\"}" # { # "entries": [ # { # ".tag": "folder", # "name": "test", # "parent_shared_folder_id": "1990893360", # "id": "id:hro-cp_zmJAAAAAAAAAACg", # "sharing_info": { # "read_only": false, # "parent_shared_folder_id": "1990893360", # "traverse_only": false, # "no_access": false # } # }, # { # ".tag": "folder", # "name": "test folder in team folder", # "parent_shared_folder_id": "1990893360", # "id": "id:hro-cp_zmJAAAAAAAAAADw", # "shared_folder_id": "3980274560", # "sharing_info": { # "read_only": false, # "parent_shared_folder_id": "1990893360", # "shared_folder_id": "3980274560", # "traverse_only": false, # "no_access": false # } # } # ], # "cursor": "...", # "has_more": false # }The paths aren't returned because this call isn't rooted anywhere; i.e., there's no root for the paths to be mounted relative to.
Instead, you can supply the path root using the 'Dropbox-API-Path-Root' header (from the Namespace Guide), like this:
curl -X POST https://api.dropboxapi.com/2/files/list_folder \ --header "Authorization: Bearer <ACCESS_TOKEN>" \ --header "Dropbox-API-Select-Admin: <ADMIN_USER_ID>" \ --header 'Dropbox-API-Path-Root: {".tag": "root", "root": "1990815600"}' \ --header "Content-Type: application/json" \ --data "{\"path\": \"ns:1990893360\"}" # { # "entries": [ # { # ".tag": "folder", # "name": "test", # "path_lower": "/team folder 1/test", # "path_display": "/team folder 1/test", # "parent_shared_folder_id": "1990893360", # "id": "id:hro-cp_zmJAAAAAAAAAACg", # "sharing_info": { # "read_only": false, # "parent_shared_folder_id": "1990893360", # "traverse_only": false, # "no_access": false # } # }, # { # ".tag": "folder", # "name": "test folder in team folder", # "path_lower": "/team folder 1/test folder in team folder", # "path_display": "/team folder 1/test folder in team folder", # "parent_shared_folder_id": "1990893360", # "id": "id:hro-cp_zmJAAAAAAAAAADw", # "shared_folder_id": "3980274560", # "sharing_info": { # "read_only": false, # "parent_shared_folder_id": "1990893360", # "shared_folder_id": "3980274560", # "traverse_only": false, # "no_access": false # } # } # ], # "cursor": "...", # "has_more": false # } - rk907 years agoHelpful | Level 5
Yes, I am not supplying the 'with root path' header. What about the deleted files/folders? There are several that don't return the path_display.
- Greg-DB7 years ago
Dropbox Community Moderator
Can you share a bit of sample code/output for that case so I can take a look? Thanks in advance!
- rk907 years agoHelpful | Level 5
for namespace_list in session.post('2/team/namespaces/list'): for namespace in namespace_list: for listing in session.post('2/files/list_folder', headers={'Dropbox-API-Select-Admin': <team_member_id>}, json={'path': f'ns:{namespace[namespace_id]}', 'recursive': True, 'include_deleted': True}): for item in listing: print(item)Above is an example of the approach I am taking to list all folders. Part of the problem is if a folder is shared with all members, then when I list 'team_member_folders' I am listing the same folder multiple times.
- Greg-DB7 years ago
Dropbox Community Moderator
Thanks! The omission of the path on the deleted entries in this case would be for the same reason as mentioned in my previous post yesterday; i.e., without the path root there's no root for the paths to be mounted relative to.
For shared folders, the shared folder ID will be consistent across users, so you can keep a list of the IDs you've seen already, and skip them when you come across them again.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!