How to upload a file to Google Drive using a Python script?

GJ. picture GJ. · May 31, 2012 · Viewed 56.6k times · Source

I need to backup various file types to GDrive (not just those convertible to GDocs formats) from some linux server.

What would be the simplest, most elegant way to do that with a python script? Would any of the solutions pertaining to GDocs be applicable?

Answer

Claudio Cherubino picture Claudio Cherubino · May 31, 2012

You can use the Documents List API to write a script that writes to Drive:

https://developers.google.com/google-apps/documents-list/

Both the Documents List API and the Drive API interact with the same resources (i.e. same documents and files).

This sample in the Python client library shows how to upload an unconverted file to Drive:

http://code.google.com/p/gdata-python-client/source/browse/samples/docs/docs_v3_example.py#180