I need my app to upload files, on the GDrive account, that can be listed and read by other user accounts (same app, other devices)
I am uploading files from aUserFileCreator@gmail.com and set the permission to anyone/reader + make it public with allowFileDiscovery
File file = driveService.files()
.create(fileMetadata, mediaContent)
.setFields("id")
.setSupportsAllDrives(true)
.setIgnoreDefaultVisibility(true)
.execute();
Permission p = new Permission();
p.setType("anyone");
p.setRole("reader");
p.setAllowFileDiscovery(true);
driveService.permissions()
.create(file.getId(), p)
.execute();
Share the file later with TheUserToListAndRead@gmail.com
Permission accessPermission = new Permission();
accessPermission.setEmailAddress("TheUserToListAndRead@gmail.com");
accessPermission.setType("user");
accessPermission.setRole("reader");
driveService.permissions().create(fileId, accessPermission).execute();
When trying to list the files, like below, I am not getting anything back but the files are visible in the Drive app of TheUserToListAndRead@gmail.com
FileList result = driveService.files().list()
.setQ("not 'me' in owners")
.setIncludeItemsFromAllDrives(true)
.setSupportsAllDrives(true)
.setSpaces("drive,appDataFolder")
.setCorpora("allDrives")
.execute();
Alternatively I used setQ("sharedWithMe")
with no success
The code works for files in the readers Drive account (only created and owned by the reader) when I remove setQ completely or set it to a mime-type of some sort