REGISTER NOW: Supercharge Your Cloud Integrations and Watch Our Webinar Recording

Kloudless Blog

Tutorials, case studies and how-tos from our experts

Monday Mentorship: Using Python to Upload a File to Dropbox

Photo by Samuel Zeller on Unsplash

“If we always helped one another, no one would need luck.”

It’s Monday, and that means we’re back with another post aimed at helping you overcome some of the most commonly asked questions about the APIs we work with here at Kloudless. Every Monday, we will aim to help answer some of the more repeated inquiries into the world’s most popular APIs or cloud services. Today, we will be turning back to one of the industry’s top names when it comes to cloud storage: Dropbox.

Boasting more than 500 million users, DropBox has been a bona fide giant of the cloud-based file storage world since its release in 2008. DropBox became the first of the ‘folder sync’ storage applications to become a household name, having been originally conceived when one of its co-founders left his USB flash drive at home and was stuck with no way to access his necessary files for a college class. As a result, DropBox has become ubiquitous with users looking to manage their files and documents in the cloud, and heavily utilized by applications looking to provide their users with storage integrations.

When Dropbox updated its API to Version 2, a lot of changes were put into effect. Many of these changes were reflected in the official Dropbox SDKs, and due to large swaths of functionality changing, a good handful of the associated functions were deprecated. Python — continually one of the most popular programming languages — fell victim to some of these deprecations, and a major ask of some of our readers was, “How the heck do I upload files to Dropbox now?!”

Well, rest assured. It’s still pretty easy. Let’s walk through it!


First, make sure that you’ve installed the Dropbox Python module by entering the following into your terminal:

Next, head over to the Dropbox developer portal and create an app here:

https://www.dropbox.com/developers/apps

Make sure that your app has a data access type of “Files & Datastores,” and set your permission type to “Full Dropbox.” This will ensure that your app has write access, so you won’t run into any errors when uploading files from your script.

Finally, click “generate access token” and copy down the string that is produced. We’ll need that for your script to properly work, and we’ll plug it in below where the script calls for it.

Great, that’s all we need to do on Dropbox’s side, so let’s take a look at the script we’ll be using. We’ve separated the functionality into a Class object and another separate function. Make sure you don’t forget to import the Dropbox library at the top.

That’s all there is to it! You can now use this script to upload files to your Dropbox app with Python!


We’d love to hear from you on any API questions you may want us to answer in the future, so please send any requests to hello@kloudless.com.

Published By

David Hallinan

David Hallinan is an Integration Strategist and Head of Content at Kloudless. He enjoys painting, JavaScript, vintage synths, drum machines and forcing his sports allegiances on his children.

View all posts by David Hallinan