Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

pkd's avatar
pkd
Explorer | Level 3
3 years ago

How do I upload file using Python

I've checked here and over at StackOverflow but couldn't find a solution. Nothing works.

It says that I need refresh token (I have no clue where to get it) and an app key.

 

 

import pathlib
import dropbox

dropbox_access_token="my_token"
app_key="my_app_key"

folder = pathlib.Path(".")
filename = "img.jpg"
filepath = folder / filename

target = "/app_folder_dropbox/"
targetfile = target + filename

d = dropbox.Dropbox(dropbox_access_token, app_key=app_key)

with filepath.open("rb") as f:
    meta = d.files_upload(f.read(), targetfile, mode=dropbox.files.WriteMode("overwrite"))

 

 

Is there simple Python script that lets you upload an image to Dropbox?

11 Replies

Replies have been turned off for this discussion

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!