Raspberry Pi Dropbox Uploader in Python

This tutorial will show you how to create a Raspberry Pi Dropbox Uploader in Python. It is based off of Andrea Fabrizi’s github project.

Start: Raspberry Pi Dropbox Uploader Tutorial

Step 1: Download the github project to your Raspberry Pi /home/pi Directory

Run this:

git clone https://github.com/andreafabrizi/Dropbox-Uploader.git

DropboxUploader

 

Step 2: Setup Dropbox Uploader

A configuration wizard will walk you through the necessary setup for the Dropbox App. Head to https://www.dropbox.com/developers/apps to create a new Dropbox App. I chose these settings:

RaspberryPiDropboxUploaderSettings

 

You will need this information:

DropboxAppStuffRaspberryPi

 

Step 3: Using the Uploader

I am going to create a test file to upload.

Then enter some random text and exit with CTRL-X, press y, and then hit enter. To see what files we have to work with run the command

To create a directory in your Dropbox run the command:

I will be creating a directory in /Apps/ and then uploading files to that directory.

 

You should then be able to go to your Dropbox account and see the PythonUploader folder in the Apps directory. /Apps/PythonUploader.

PythonDropboxUploader

 

Let’s upload our test file by running the command:

PythonRaspberryPiDropbox

Step 4: Python Scripts Using the Dropbox Uploader

I will be creating several python scripts that have different functions for uploading files to Dropbox. Here is a script that will ask the user for different parameters based on what they would like to do with their Dropbox.

 

 

 

Full Documentation

  • upload <LOCAL_FILE/DIR …> <REMOTE_FILE/DIR>
    Upload a local file or directory to a remote Dropbox folder.
    If the file is bigger than 150Mb the file is uploaded using small chunks (default 4Mb); in this case a . (dot) is printed for every chunk successfully uploaded and a * (star) if an error occurs (the upload is retried for a maximum of three times). Only if the file is smaller than 150Mb, the standard upload API is used, and if the -p option is used the default curl progress bar is displayed during the upload process.
    The local file/dir parameter supports wildcards expansion.
  • download <REMOTE_FILE/DIR> [LOCAL_FILE/DIR]
    Download file or directory from Dropbox to a local folder
  • delete <REMOTE_FILE/DIR>
    Remove a remote file or directory from Dropbox
  • move <REMOTE_FILE/DIR> <REMOTE_FILE/DIR>
    Move or rename a remote file or directory
  • copy <REMOTE_FILE/DIR> <REMOTE_FILE/DIR>
    Copy a remote file or directory
  • mkdir <REMOTE_DIR>
    Create a remote directory on DropBox
  • list [REMOTE_DIR]
    List the contents of the remote Dropbox folder
  • share <REMOTE_FILE>
    Get a public share link for the specified file or directoryinfo
  • Print some info about your Dropbox account
  • unlink
    Unlink the script from your Dropbox account

Optional parameters:

  • -f <FILENAME>
    Load the configuration file from a specific file
  • -s
    Skip already existing files when download/upload. Default: Overwrite
  • -d
    Enable DEBUG mode
  • -q
    Quiet mode. Don’t show progress meter or messages
  • -p
    Show cURL progress meter
  • -k
    Doesn’t check for SSL certificates (insecure)

Examples:

 

 

 

1 Response

  1. jack says:

    hey this is great,
    Just wondering what changes would I need to make in order to run this from the crontab -e, @reboot

Leave a Reply

Your email address will not be published. Required fields are marked *