I have a shared folder in a shared Google Drive
https://gyazo.com/ae22a1d04eeddf9de49adbf470706ac8
I'm trying to upload a file to this team google drive using Pydrive. This code works for uploading to a specific folder in my drive but not in any of the folders in the shared drive.
file_drive = drive.CreateFile({'title': file_name,
"parents": [{"kind": "drive#fileLink", "id": folder_id}]})
file_drive.SetContentFile(f.name)
file_drive.Upload()
I have full access to all of the files as well as permissions for creating/deleting files/folders. Can anyone give me a hint?
As I was writing this, I stumbled upon the following thread...
https://github.com/gsuitedevs/PyDrive/issues/149
This issue can easily be fixed with the following code and using the 'supportsTeamDrives' and '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})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.