![](/img/trans.png)
[英]List all files in folder in shared Google Team Drive using PyDrive
[英]'Method Not Allowed' when using pydrive to upload files to a shared folder in a shared Google Drive
我在共享的 Google 云端硬盘中有一个共享文件夹
https://gyazo.com/ae22a1d04eeddf9de49adbf470706ac8
我正在尝试使用 Pydrive 将文件上传到这个团队的谷歌驱动器。 此代码适用于上传到我的驱动器中的特定文件夹,但不适用于共享驱动器中的任何文件夹。
file_drive = drive.CreateFile({'title': file_name,
"parents": [{"kind": "drive#fileLink", "id": folder_id}]})
file_drive.SetContentFile(f.name)
file_drive.Upload()
我拥有对所有文件的完全访问权限以及创建/删除文件/文件夹的权限。 谁能给我一个提示?
在写这篇文章的时候,我偶然发现了以下线程......
https://github.com/gsuitedevs/PyDrive/issues/149
使用以下代码并使用“supportsTeamDrives”和“teamDriveId”arguments,可以轻松解决此问题。
file_drive = drive.CreateFile({
'title': fn,
'parents': [{
'kind': 'drive#fileLink',
'teamDriveId': team_drive_id,
'id': folder_id
}]
})
file_drive.SetContentFile(f.name)
file_drive.Upload(param={'supportsTeamDrives': True})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.