1

Need to know how to do the same in shared drive.

I was able to create a subfolder in my drive using:

file_metadata = {
            'supportsAllDrives':True,
            'parents': ['twLBZwLdxfBKTEX0VUUr6'],
            'name': "new folderrrrr sub",
            'mimeType': 'application/vnd.google-apps.folder',
        }

file = DRIVE.files().create(body=file_metadata,
                            fields='id', supportsAllDrives=True, supportsTeamDrives=True).execute()```

1 Answer 1

1

I grasp that you want to upload a folder filled with files in a shared drive. If that isn't your question, please forgive me. To accomplish that you'll need editing permission to be able to write into that shared drive. With that on mind, your operation can be divided into two steps:

  1. First you want to create a folder inside the shared drive in a way similar as this one. As the parents[] you have to use the id property of the shared drive (you can get it by using the LIST method).
  2. After that you'll have to upload every file, one by one, with a code akin this one. You'll need to use the identifier of the folder created on the previous step and the appropriate MIME type.

For both operation you must use the CREATE method with the supportsAllDrives parameter set to true (this requirement is only needed until the first of June of 2020 as described on the linked documentation). You can read here how to set up a working Drive API environment for Python if you don't have one already. If you have any doubt or request additional help, please don't hesitate to comment on my answer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.