如何将文件从MyDrive移到Team Drive?

编程入门 行业动态 更新时间:2024-10-24 22:27:22
本文介绍了如何将文件从MyDrive移到Team Drive?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用Google Apps脚本将文件从MyDrive传输到Team Drive.我可以手动执行此操作(因此我知道我有此权限),并且启用了Drive API(因此能够保存到MyDrive).但是,当我这样做时(我从另一篇文章中得到了):

I would like to use Google Apps Script to transfer a file from MyDrive to Team Drive. I can do this manually (so I know I have permission) and I enabled the Drive API (so was able to save to MyDrive). However, when I do this (which I got from another post):

function moveFileToFolder(fileId, newFolderId) { var file = Drive.Files.get(fileId, {supportsTeamDrives: true}); Drive.Files.patch(file, fileId, { supportsTeamDrives: true, corpora: 'teamDrive', removeParents: file.parents.map(function(f) { return f.id; }), addParents: [newFolderId], }); }

我收到此错误:

Sharing restrictions cannot be set on a Team Drive item.

有什么想法吗?

推荐答案

看来我在考虑以下方面:

It appears I was overthinking it as the following works:

var file = DriveApp.getFileById(fileId); var parentFolder = DriveApp.getFolderById(TEAM_DRIVE_ID); parentFolder.addFile(file);

更多推荐

如何将文件从MyDrive移到Team Drive?

本文发布于:2023-10-31 15:35:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546523.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:移到   如何将   文件   MyDrive   Team

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!