The Java
API of Dropbox
returns a list of file owner names via a method like
public List<String> getOwners(DbxClientV2 client, String fileId) {
SharedFileMetadata metadata = client.sharing().getFileMetadata();
return metadata.getOwnerDisplayNames();
}
Is there any way of getting the e-mail addresses, too?
According to Dropbox v2 Documentation, it has endpoint - /get_file_metadata
.
Example curl
request:
curl -X POST https://api.dropboxapi.com/2/sharing/get_file_metadata \
--header "Authorization: Bearer <access token> " \
--header "Content-Type: application/json" \
--data "{\"file\": \"id:3kmLmQFnf1AAAAAAAAAAAw\",\"actions\": []}"
Parameters:
{
"file": "id:3kmLmQFnf1AAAAAAAAAAAw",
"actions": []
}
Returns:
{
"id": "id:3kmLmQFnf1AAAAAAAAAAAw",
"name": "file.txt",
"policy": {
"acl_update_policy": {
".tag": "owner"
},
"shared_link_policy": {
".tag": "anyone"
},
"member_policy": {
".tag": "anyone"
},
"resolved_member_policy": {
".tag": "team"
}
},
"preview_url": "https://www.dropbox.com/scl/fi/fir9vjelf",
"access_type": {
".tag": "viewer"
},
"owner_display_names": [
"Jane Doe"
],
"owner_team": {
"id": "dbtid:AAFdgehTzw7WlXhZJsbGCLePe8RvQGYDr-I",
"name": "Acme, Inc."
},
"path_display": "/dir/file.txt",
"path_lower": "/dir/file.txt",
"permissions": [],
"time_invited": "2016-01-20T00:00:00Z"
}
owner_display_names
List of (String)?
The display names of the users that own the file. If the file is part of a team folder, the display names of the team admins are also included. Absent if the owner display names cannot be fetched. This field is optional.
So, there are no information about user's email according to file.
To get the information about the members of a shared file with the Dropbox Java SDK, you should use the listFileMembers
* methods. There are a few versions you can choose from, depending on your use case and desired method of batching/pagination:
One way to get the owners is via the collaboration metadata:
public List<String> getOwners(DbxClientV2 client, String fileId) {
SharedFileMetadata metadata = client.sharing().getFileMetadata();
List<UserFileMembershipInfo> users = metadata.getUsers();
List<String> owners = new ArrayList<>();
for (UserFileMembershipInfo user : users)
if (user.getAccessType() == AccessLevel.OWNER) {
owners.add(info.getUser().getDisplayName());
}
return owners;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.