1

When copying a directory in google drive, I get a HTTP 500 error. The example is very basic; there are no nested directory structures, so everything takes place in the root directory (which has the id 'root'). Folders are files with the mimeType property set to 'application/vnd.google-apps.folder'. drive is an initialized instance of the class pydrive.drive.GoogleDrive. The code creates a new folder called mydirectory in the root folder. Then it fails to copy the new folder to 'copy of mydirectory' in the root directory. Since the error indicates a server error, I checked if the copy operation succeeds after waiting a few minutes and more, but the error occurs everytime.

new_folder = drive.CreateFile({'title': "mydirectory"})
new_folder['parents'] = [{"id":'root'}]
new_folder['mimeType'] = "application/vnd.google-apps.folder"
new_folder.Upload()
copied_file = {"parents": [{"id": root}], 'title': "copy of mydirectory"}
drive.auth.service.files().copy(fileId=new_folder['id'], body=copied_file).execute()
<HttpError 500 when requesting https://www.googleapis.com/drive/v2/files/0B4GMba0Qa8yITWEwQVR3bi1GYWc/copy?alt=json returned "">

Finally, what I would like to achieve is to copy the folder with all its contents. As even copying a simple folder fails, I do not know if this can be done with the copy request, or needs to be done file object by file object. How can I copy a directory remotely?

phobic
  • 914
  • 10
  • 24

0 Answers0