응용 프로그램 소유 계정을 사용하여 파일을 만듭니다. 그러나 파일 소유권을 다른 사용자에게 이전하고 싶습니다. 아래 코드는 작동하지만 권한 설정이 무시되므로 파일 소유자가 아닙니다. 파일 소유권은 응용 프로그램 소유 계정으로 유지되므로 파일을 영구적으로 삭제할 수 없습니다.권한 설정 파일을 만들 때 무시됩니다.
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("[email protected]");
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);
}
}
권한 설정이 무시되는 이유를 확인하는 데 도움이 될 것입니다.
나는 오류가 발생 점점 오전 : com.google.api.client.googleapis.json.GoogleJsonResponseException : 500 { "코드": 500, "오류": [{ "도메인": "글로벌" 내부 오류 " "이유 ":"internalError " }], "message ":"내부 오류 " }"소유권이 도메인 밖으로 전송되고 있습니까? 그렇다면 앱 별 계정은 항상 @ developer.gserviceaccount.com이기 때문에 해결책이 없습니다. – lanzalibre