Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 415
GJ. Avatar asked May 31 '12 09:05

GJ.


People also ask

How do you upload a file in Python?

Method 1: Using the Python's os Module: Also, the enctype attribute with "multi-part/form-data" value will help the HTML form to upload a file. Lastly, we need the input tag with the filename attribute to upload the file we want. Lastly, we need the input tag with the filename attribute to upload the file we want.

How do I automate Google Drive upload?

Google offers Backup and Sync, an application you can install on your computer in order to back up any folder on your computer over to Google Drive automatically. Simply install Backup and Sync and you can add any folder on your computer to automatically upload all files to Google Drive.


1 Answers

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

like image 156
Claudio Cherubino Avatar answered Sep 26 '22 19:09

Claudio Cherubino