Python script to upload files to Google Drive from the CLI
Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
client_secrets.json
config.ini
upload.py

README.md

script that pushes files in a specified directory to Google Drive and then deletes them from local disk

Usage

configure settings in the config.ini file:

[main]
target_directory = /path/to/directory/for/target/files
google_drive_credentials = mycreds.txt

running upload.py will zip/upload everything in the target_directory and then delete all it:

python upload.py

Upon the first time running the script, your browser will ask for your Google authentication. After successful authentication, a credential file will be saved in the project root directory. Do not share this file, the script will use this file to authenticate to your Google Drive.

Why not just use Google Drive app?

  1. The native desktop app does not support Linux :(
  2. There are cases in which a user may not want to keep files on their local machine, but still want them to be pushed. This script doesn't "sync" with the cloud, it just pushes to it.
  3. Having this functionality on the command line can be useful if you want to incorporate other scripts (ie cron jobs)

How to get Google Drive credentials when there is no GUI...

In order to get your Google Drive credentials, a web browser is currently required. I recommend using a machine that has a browser to retrieve and credentials and then transferring the credential file to the machine without the GUI.

Contributing/Problems

  • All of the uploaded files go to the root directory of the Google Drive. There needs to be functionality for choosing which folder the files are being uploaded to. Or at least have a specified folder instead of just dumping everything into the root folder.
  • When uploading large binaries, there is a significant CPU spike, but I am more likely to point the finger at the Python Wrapper class for this issue.
  • There ought to be an option for encryption and password before pushing the files

License

MIT License