user7770031
user7770031

Reputation:

How to add description to a google drive file in python

I want to upload a file to google drive and add a string to its description.

This is the code so far:

def upload_file(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'))

Upvotes: 0

Views: 196

Answers (1)

Tanaike
Tanaike

Reputation: 201428

You want to add the description of file when the file is uploaded. If my understanding is correct, how about this modification?

From :

file_metadata = {'name': filename}

To :

file_metadata = {
    'name': filename,
    'description': 'sample description'
}

Reference :

If I misunderstand your question, please tell me. I would like to modify my answer.

Upvotes: 1

Related Questions