Set file sharing level to 'Anyone with the link' through Google Drive API

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

Answers


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

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.


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


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

Need Your Help

iPhone SDK: Dealloc vs. Release?

iphone

I am wondering what the difference is between release and dealloc? After reading, the memory management rules (See below)., I am thinking most of the time I will be using release. However, I wante...