Set the “Anyone with a link” file sharing level through the Google Drive API

How to do it? Should I use the Google Docs ACLs instead and how to configure such an ACL?

+6
source share
3 answers

You need to set the 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(); } 
+17
source

Use this method to make your file visible to everyone:

 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
source

Source: https://habr.com/ru/post/918749/


All Articles