【发布时间】:2019-04-18 17:11:49
【问题描述】:
我想使用来自 AppmMaker 的脚本将文件从 MyDrive 传输到 TeamDrive。我使用 DriveApp 在 MyDrive 中创建文件,并使用来自 appmaker 的 DrivePicker 小部件,我从目标文件夹获取 id 以保存文件。 DriveApp 可以在 TeamDrive 中移动文件
var file = DriveApp.getFileById(fileId);
var parentFolder = DriveApp.getFolderById(TEAM_DRIVE_ID);
parentFolder.addFile(file);
但不在 TeamDrive 的文件夹中。
我已尝试使用此代码:
function moveFileToFolder(fileIds, newFolderId) {
var file = Drive.Files.get(fileIds, {supportTeamDrives: true,supportsTeamDrives: true});
Drive.Files.patch(file, fileIds, {
removeParents: file.parents.map(function(f) { return f.id; }),
addParents: [newFolderId],
supportTeamDrives: true,
supportsTeamDrives: true
});
}
我遇到错误“无法在团队云端硬盘项目上设置共享限制”。
参考:How to move a file from MyDrive to Team Drive?
(引用的解决方案不起作用,因为我想将其移动到 teamdrive 的文件夹中,而不是直接在 teamdrive 中)
有什么想法吗?
【问题讨论】:
-
尝试使用
update而不是patch,或者如果您需要继续使用patch,请明确删除云端硬盘文件中存在但团队云端硬盘文件中不存在的各种不适用的元数据属性. -
感谢您的回答。
update返回相同的错误,我没有找到任何关于如何删除这些元数据的文档。 -
您可以显式控制文件元数据,因此获取现有元数据,从返回的对象中删除不适用的属性,然后将其作为移动文件的新元数据提供。
标签: google-apps-script google-app-maker google-drive-shared-drive