0
にサブフォルダを作成するにはどうすれば私はGoogle Drive APIs
間TeamDrive API
について疑問に思ってGoogle Drive API
JAVA
と、 使用して小規模なシステムを開発しています。GoogleドライブAPI - チームドライブ
まず第一に、私は、チーム・ドライブ・フォルダを作成し
はチームドライブ
public static void createTeamDrive(String accessToken) throws IOException {
long startTime = System.currentTimeMillis();
TeamDrive teamDriveMetadata = new TeamDrive();
teamDriveMetadata.setName("Team Drive API Test");
String requestId = UUID.randomUUID().toString();
TeamDrive teamDrive = getDriveService(accessToken).teamdrives().insert(requestId, teamDriveMetadata).execute();
System.out.println("[Create TeamDrive] execution time : " + (System.currentTimeMillis() - startTime));
}
を作成し、私は、ユーザーが共有しました。
共有ユーザー
public static Permission ShareUser(String teamDriveFolderId, String googleMail, String accessToken) {
long startTime = System.currentTimeMillis();
Permission userPermission = new Permission().setRole("reader")
.setType("user").setEmailAddress(googleMail)
.setValue(googleMail).setWithLink(false);
try {
userPermission = getDriveService(accessToken).permissions().insert(teamDriveFolderId, userPermission)
.setSupportsTeamDrives(true).execute();
System.out.println(userPermission.toPrettyString());
} catch (IOException e) {
System.out.println(e);
}
System.out.println("[Give Permission] execution time : " + (System.currentTimeMillis() - startTime));
return userPermission;
}
そして私は 、グーグルドライブライブラリを複数回使用してサブフォルダを作成しようとしました。しかし、私は継続的にサブフォルダを作成することができませんでした。
私は私はこのような404応答を取得することができます 'createSubfolderFunction' を呼び出すとサブフォルダ
public static void createSubFolder(String accessToken, String teamDriveFolderId) throws IOException {
long startTime = System.currentTimeMillis();
File fileMetaData = new File();
fileMetaData.setTitle("SubFolder Title ");
fileMetaData.setMimeType("application/vnd.google-apps.folder");
fileMetaData.setTeamDriveId(teamDriveFolderId);
fileMetaData.setParents(Arrays.asList(new ParentReference().setId(teamDriveFolderId)));
fileMetaData.set("supportsTeamDrives", true);
fileMetaData.set("fields", "id");
File file = null;
try {
file = getDriveService(accessToken).files().insert(fileMetaData).execute();
System.out.println(file.getId());
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("[Create Sub folder] execution time : " + (System.currentTimeMillis() - startTime));
}
を作成します。
com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
"code" : 404,
"errors" : [ {
"domain" : "global",
"location" : "file",
"locationType" : "other",
"message" : "File not found: 0AHGrQOmlzQZUUk9PVA",
"reason" : "notFound"
} ],
"message" : "File not found: 0AHGrQOmlzQZUUk9PVA"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
'0AHGrQOmlzQZUUk9PVA' is the exact result from createTeamDrive function.
私はこの質問に言及しました。 enter link description here
私のソースコードを見て、何が間違っているかを指摘してください。