Learn how to make the most out of the Dropbox Community here 💙!
Forum Discussion
zapredelom
2 months agoNew member | Level 1
can't get path_lower and path_display from file metadata
def get_file_metadata(self, file_path: str):
"""
Retrieves the metadata of a file in Dropbox.
"""
try:
metadata = self.dbx_team.as_admin(self.admin_id).files_get_metadata(file_path)
return metadata
except Exception as e:
print(f"Error retrieving file metadata for {file_path}: {e}")
return None
# return value JSON serialized
{'size': 806571,
'preview_url': None,
'sharing_info': {'modified_by': '****',
'read_only': False,
'parent_shared_folder_id': '****'},
'client_modified': '2022-01-10T13:45:52',
'file_lock_info': None,
'is_downloadable': True,
'rev': '****',
'name': '_file_name_.pdf',
'media_info': None,
'id': 'id:****',
'property_groups': None,
'content_hash': '****',
'export_info': None,
'path_display': None,
'parent_shared_folder_id': '****',
'server_modified': '2024-01-16T20:15:15',
'symlink_info': None,
'path_lower': None,
'has_explicit_shared_members': None}
Above, you can see the example code and the return value. I'm trying to get the file metadata and read path_display, but the field is always empty. Is this an expected behavior?
- DB-Des
Dropbox Engineer
Hi zapredelom,
If that path values are not set, that indicates that the item is not mounted under the account for that call.
In you case, you are using as_admin to administratively access team content on behalf of an admin, who may not necessarily have that content mounted on their account.
To get path_display and path_lower values, the request to the API will need to be made in the context where the content is actually mounted. You can use one of the following options:
- Use with_path_root using the root of the account where the content is actually mounted
- Use as_user instead of as_admin
About Discuss Dropbox Developer & API
Make connections with other developers810 PostsLatest Activity: 18 hours ago
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!