Given a google drive link, how to upload a file in that directory using python.
Asked
Active
Viewed 428 times
-2
-
2Does this answer your question? [How to upload a file to Google Drive using a Python script?](https://stackoverflow.com/questions/10830820/how-to-upload-a-file-to-google-drive-using-a-python-script) – Binh Mar 30 '20 at 07:44
-
Questions seeking recommendations for books, software libraries, or other off-site resources. This question is likely to lead to opinion-based answers. Show us what you have tried. – Linda Lawton - DaImTo Mar 30 '20 at 08:10
1 Answers
0
You can use the google-api-python-client
, see here.
You probably want to use the create method, e.g. like this:
file_metadata = {'name': 'photo.jpg'}
media = MediaFileUpload('files/photo.jpg',
mimetype='image/jpeg')
file = drive_service.files().create(body=file_metadata,
media_body=media,
fields='id').execute()
print 'File ID: %s' % file.get('id')
Code taken from the documentation.

yvesonline
- 4,609
- 2
- 21
- 32