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
rahulj1
2 years agoExplorer | Level 4
Access Shared Folder with API
Hi Team, can any one please help me to get access in shared folder to extract the meta data like subfolder size and file count. I was unable to locate the shared folder through api always it say...
rahulj1
Explorer | Level 4
Hi,
Thanks for your response.
Could you please provide sample code snippet to extract size and count from a team folder?
Greg-DB
2 years agoDropbox Staff
rahulj1 You'll need to write and test your own code to suit your particular use case, but it might look something like this:
import dropbox
dbx = dropbox.DropboxTeam(ACCESS_TOKEN).as_user(TEAM_MEMBER_ID)
root_namespace_id = dbx.users_get_current_account().root_info.root_namespace_id
dbx = dbx.with_path_root(dropbox.common.PathRoot.root(root_namespace_id))
total_file_size = 0
total_file_count = 0
def handle_entries(entries):
size = 0
count = 0
for entry in entries:
if (isinstance(entry, dropbox.files.FileMetadata)):
size += entry.size
count += 1
return size, count
folder_path = ""
res = dbx.files_list_folder(path=folder_path, recursive=True)
add_file_size, add_file_count = handle_entries(res.entries)
total_file_size += add_file_size
total_file_count += add_file_count
while res.has_more:
res = dbx.files_list_folder_continue(cursor=res.cursor)
add_file_size, add_file_count = handle_entries(res.entries)
total_file_size += add_file_size
total_file_count += add_file_count
print("total file size: " + str(total_file_size))
print("total file count: " + str(total_file_count))
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,883 PostsLatest Activity: 8 hours agoIf 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!