I am using Application Owned Accounts to create a file. However, I would like the ownership of the file to be transfered to other users. The code below works but permission settings are ignored, so I am not the owner of the file. File ownership stays with the Application Owned Account, so files cannot be deleted permanently.
public File uploadEmptyFile(String title, String subFolderName, String mimetype) throws GDriveAccessException {
File fileMetadata = new File();
fileMetadata.setTitle(title);
fileMetadata.setMimeType(mimetype);
Permission newPermission = new Permission();
newPermission.setValue("xxx@xyz.com");
newPermission.setType("user");
newPermission.setRole("owner");
fileMetadata.setUserPermission(newPermission);
if (subFolderName==null){
fileMetadata.setParents(Arrays.asList(new ParentReference().setId(FOLDER_ID)));
}else{
fileMetadata.setParents(Arrays.asList(new ParentReference().setId(getFileIdByFolderNName(null,subFolderName))));
}
File faux=null;
try {
faux= getDrive().files().insert(fileMetadata).execute();
return faux;
} catch (IOException e1) {
throw new GDriveAccessException(e1);
}
}
Any help in identifying why the permission settings are being ignored would be welcome.