pythongoogle-drive-realtime-apigoogle-drive-shared-drive

GDRIVE API with python


I'm doing a little executable where I upload a file on google drive, but that's not exactly what I wanted. I would like to do a versioning of files on google drive, so as not to take up too much disk space.

My code for upload files

def uploadFile(filename,filepath,mimetype):
file_metadata = {'name': filename}
media = MediaFileUpload(filepath,
                        mimetype=mimetype)
file = drive_service.files().create(body=file_metadata,
                                    media_body=media,
                                    fields='id').execute()
print('File ID: %s' % file.get('id'))

I think I have to change the files.create to another, can you help me with that?


Solution

  • Read Manage Revisions:

    You be using revisions.list to get the different versions of a single file and revisions.get to operate on a specific version.