简体   繁体   English

Dropbox Java API-文件所有者的电子邮件

[英]Dropbox Java API - File owner emails

The Java API of Dropbox returns a list of file owner names via a method like DropboxJava API通过类似的方法返回文件所有者名称的列表

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 . 根据Dropbox v2文档,它具有终结点- /get_file_metadata

Example curl request: curl请求示例:

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)? 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. 要使用Dropbox Java SDK获取有关共享文件成员的信息,应使用listFileMembers *方法。 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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM