v3
I'd simply like to update a single Doc on the user's drive.
But in order to do this, it seems I need to download the file first, then edit the doc, and finally upload it. I'm thinking I also need to delete the old file, in order to upload the edited file under the same name.
This all seems a bit overcomplicated.
With the google drive API, how can I directly edit an existing file on the user's drive?
I found documents and code examples for downloading files, and uploading files, but the docs for updating files has me a little lost as the "required query parameter" links back to the upload page...
Does this mean that I can use the same code as an upload?:
file_metadata = {'name': 'essay.doc'}
media = MediaFileUpload('files/essay.doc',
mimetype='text/plain')
file = drive_service.files().create(body=file_metadata,
media_body=media,
fields='id').execute()
print 'File ID: %s' % file.get('id')
If that's the case, where does the logic to check for an existing file come in? How does it handle uploading a file when that file already exists in the drive?
I'm simply trying to check that a file on the drive exists, create one if it doesn't, then append a bunch of text to the content of the document.