0

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?

erb13020
  • 325
  • 1
  • 4
  • 7

1 Answers1

0

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})
erb13020
  • 325
  • 1
  • 4
  • 7