Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
pkd
3 years agoExplorer | Level 3
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
- Greg-DB3 years ago
Dropbox Community Moderator
pkd No, you need to use the OAuth app authorization flow to get a refresh token. Dropbox doesn't offer another way of getting a refresh token.
If you only need this for your own account though, you could run that manually once, e.g., as shown in this example using curl. (The use of redirect_uri is actually optional so you can just omit that parameter.)
About 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!