我有下一个分享 Google Drive 文件的方法:
public static boolean shareFile(HttpServletRequest httpReq, String fileId, String user, String rol, boolean commenter) {
Drive service = getService(httpReq) ;
if (service != null){
Permission newPermission = new Permission();
newPermission.setValue(user);
newPermission.setType("user");
newPermission.setRole(rol);
if (commenter)
newPermission.setAdditionalRoles(Arrays.asList("commenter"));
try {
service.permissions().insert(fileId, newPermission).execute();
return true;
} catch (Exception e) {
System.out.println("An error occured: " + e);
}
}
return false;
}
当变量 commenter 为 false 时一切正常(我们不设置其他角色),但如果我希望用户具有角色“reader”和“commenter”,我会收到下一个错误:
发生错误:com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error { “代码”:500, “错误”:[{ “域”:“全球”, “消息”:“内部错误”, “原因”:“内部错误” }], “消息”:“内部错误” }
有没有人遇到过这种问题?