Skip to content

torpedro/gdrive-lib

Repository files navigation

Google Drive Lib

Build Status

This is a library to write simple Google Drive management/backup tools using Python.

Usage

After quickly setting up the environment you can run the google drive commander like this:

# List files in the root directory
bin/gdrive ls /

# Download a file
bin/gdrive scp drive:/test.pdf ~/test.pdf

# Upload a file
bin/gdrive scp ~/test.pdf drive:/test.pdf

# Download a sheet as CSV
bin/gdrive csv-download "/My Spreadheet" "Sheet 1" ~/output.csv

# Upload a CSV into a spreadsheet
bin/gdrive csv-upload "/My Spreadsheet" "Upload" ~/upload.csv

Setup

You need to only do two small things to be able to access the Google Drive API. You need to set up the python environment with the relevant libraries and set up permissions in the Drive itself. Below is information on how to do both of these things.

Setting up the Python Environment

You'll need to run the following commands to setup the virtual environment and download the packages:

python3 -m venv .google-drive-venv
source .google-drive-venv/bin/activate
pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib oauth2client mypy pylint

Setting up the Google Drive API permissions

To use the Google Drive API you need to do step 1 and step 2 as outlined in these docs (this needs to be done only once): https://developers.google.com/drive/api/v3/quickstart/python

You can see your live projects here: https://console.cloud.google.com/

Then you'll need to move the credentials.json and token.json files either to where you are running the gdrive binary from or pass the location in using the arguments gdrive --token ~/token.json --creds ~/creds.json.

Documentation

Drive API Docs

Sheets API Docs

About

Library and tools to search, upload and download files within the Google Drive and in Google Sheets

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published