Christina Christina - 5 months ago 56x
Python Question

upload file to my dropbox from python script

I want to upload a file from my python script to my dropbox account automatically. I can't find anyway to do this with just a user/pass. Everything I see in the Dropbox SDK is related to an app having user interaction. I just want to do something like this:

Please help, thanks!


Thanks to @smarx for the answer above! I just wanted to clarify for anyone else trying to do this.

  1. Make sure you install the dropbox module first of course, pip install dropbox.

  2. Create an app under your own dropbox account in the "App Console". (

  3. Just for the record I created my App with the following:

    a. App Type as "Dropbox API APP".

    b. Type of data access as "Files & Datastores"

    c. Folder access as "My app needs access to files already on Dropbox". (ie: Permission Type as "Full Dropbox".)

  4. Then click the "generate access token" button and cut/paste into the python example below in place of <auth_token>:

import dropbox client = dropbox.client.DropboxClient(<auth_token>) print 'linked account: ', client.account_info() f = open('working-draft.txt', 'rb') response = client.put_file('/magnum-opus.txt', f) print 'uploaded: ', response folder_metadata = client.metadata('/') print 'metadata: ', folder_metadata f, metadata = client.get_file_and_metadata('/magnum-opus.txt') out = open('magnum-opus.txt', 'wb') out.write( out.close() print metadata