设置文件共享级别为“知道链接的人”通过谷歌云端硬盘API(Set file sharing leve

2019-06-25 16:42发布

怎么做? 我应该使用谷歌文档,而不是ACL以及如何配置这样的ACL?

Answer 1:

你必须设置以下参数:

private Permission insertPermission(Drive service, String fileId) throws Exception{
   Permission newPermission = new Permission();
   newPermission.setType("anyone");
   newPermission.setRole("reader");
   newPermission.setValue("");
   newPermission.setWithLink(true);
   return service.permissions().insert(fileId, newPermission).execute();
}


Answer 2:

使用此方法,使您的文件中看到任何人:

private static Permission insertPermission(Drive service, String fileId) throws IOException
{
    Permission newPermission = new Permission();
    newPermission.setType("anyone");
    newPermission.setRole("reader");

    return service.permissions().insert(fileId, newPermission).execute();
}

更多细节在这里 。



Answer 3:

你必须使用的文档列表API来管理共享。 请检查文档https://developers.google.com/google-apps/documents-list/#managing_sharing_permissions_of_resources_via_access_control_lists_acls



Answer 4:

对于谷歌云端硬盘API V3,使用此方法,使您的文件中看到任何人:

    private Permission InsertAnyonePermissionToDownload(Google.Apis.Drive.v3.DriveService service, String fileId)
    {
        Permission newPermission = new Permission();
        newPermission.Type = "anyone";
        newPermission.Role = "reader";
        return service.Permissions.Create(newPermission, fileId).Execute();
    }


文章来源: Set file sharing level to 'Anyone with the link' through Google Drive API