我正在尝试创建一个脚本,该脚本可以将文件从 Team Drive 迁移到 Personal Drive 。
我设法将文件从Personal Drive
移到Team Drive
。但是,当我要将文件移回Personal Drive
时,会出现此错误:
{“错误”:{“错误”:[{“域”:“全局”,“原因”:“未找到”,“消息”:“未找到文件:1cI_gUJyVFGF-_U6umbMVJFoRcvzOQoB2。”,“ locationType”: “,”参数“,”位置“:” fileId“}],”代码“:404,”消息“:”找不到文件:1cI_gUJyVFGF-_U6umbMVJFoRcvzOQoB2“。 }
这是我的脚本:
//The file on the Team Drive
$fileId = '1cI_gUJyVFGF-_U6umbMVJFoRcvzOQoB2';
//The folder id from the personal Drive
$folderId = '1uXONHLA7jUUDxvc-puqyHdMOWRSvvSys';
$emptyFileMetadata = new Google_Service_Drive_DriveFile();
$file = $driveService->files->get($fileId, array('fields' => 'parents'));
$previousParents = join(',', $file->parents);
$file = $driveService->files->update($fileId, $emptyFileMetadata, array(
'addParents' => $folderId,
'removeParents' => $previousParents,
'fields' => 'id, parents',
'supportsTeamDrives' => 'true',
));