Set file sharing level to 'Anyone with the lin

2019-01-11 20:57发布

问题:

How to do that? Should I use Google Docs ACL instead and how to configure such ACL?

回答1:

you have to set following parameters :

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();
}


回答2:

Use this method to make your file visible to anyone:

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();
}

More details here.



回答3:

You have to use the Documents List API to manage sharing. Please check the docs at https://developers.google.com/google-apps/documents-list/#managing_sharing_permissions_of_resources_via_access_control_lists_acls



回答4:

For Google Drive API V3, use this method to make your file visible to anyone:

    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();
    }