0

With file uploaded and file_id known:

media_body = MediaFileUpload(filepath, mimetype=mimetype)
body = {'name': os.path.basename(filepath), 'appProperties':{'my_key': 'my_value'}}
file = drive_service.files().create(body=body, media_body=media_body, fields='id, appProperties').execute()
file_id = file['id']

How to modify the file's appProperties using v3?

There is a Google Drive API v3 Migration post that could be used to get some idea on things not covered in the documentaion. This post's Trash / Update section talks about update functionality in Google Drive API v3. But it is written in Java and not Python. It suggests of using an empty File object: File newContent = new File();

Another post this time for PHP mentions about update method and this empty File approach too: How to update file in google drive v3 PHP

I would appreciate if someone here would trough a couple of Python snippets to guide me in a right direction.

alphanumeric
  • 17,967
  • 64
  • 244
  • 392

1 Answers1

1

How about following sample? In order to update appProperties, you can use drive.files.update. The detail information is here.

Sample script :

body = {'appProperties': {'my_key': 'updated_my_value'}}
updated_file = drive_service.files().update(
    body=body,
    fileId="### file id ###",
    fields='id, appProperties'
).execute()

If I misunderstand your question, I'm sorry.

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • I was using a wrong flag. It must be a `body` flag. – alphanumeric Aug 07 '17 at 00:35
  • 1
    @Kishan Mehta You can create and update spreadsheet using Sheets API v4. You can see the detail information here https://developers.google.com/sheets/api/reference/rest/ – Tanaike Sep 19 '17 at 09:03