1

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?

PNS
  • 19,295
  • 32
  • 96
  • 143

3 Answers3

1

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.

BSeitkazin
  • 2,889
  • 25
  • 40
  • Yes, that has been my impression too. I am hoping that somehow this information is available, as is in other cloud storage systems, like Google Drive and Box. Thanks anyway and +1. – PNS Jul 24 '19 at 04:36
0

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;
}
PNS
  • 19,295
  • 32
  • 96
  • 143