"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

April 11, 2018

Day #104 - Working with DropBox

Python script to upload and download from dropbox. Install the dropbox package, get access token by signing up for dropbox. Create an app in dropbox console - Create an App on dropbox console (https://www.dropbox.com/developers/apps) and obtain access token


#Upload to drop box
import dropbox
access_token = 'XXXX'
#upload from local to dropbox
file_from = 'Pics.jpg' #local file path
file_to = '/Pics.jpg' # dropbox path
def upload_file(file_from, file_to):
dbx = dropbox.Dropbox(access_token)
f = open(file_from, 'rb')
dbx.files_upload(f.read(), file_to)
upload_file(file_from,file_to)
#Download from drop box to local
dbx = dropbox.Dropbox(access_token)
dbx.files_download_to_file('download1.jpg', '/'+ file_from)
view raw dropbox.py hosted with ❤ by GitHub
Happy Learning!!!


No comments: