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...
Здравко
3 years agoLegendary | Level 20
pkd wrote:Thank you but this is not what I asked for. I thought that there exists simple script that lets you ulpoad files to Dropbox.
...
🤔Did you test the above script? It can perform upload of one or more files in pointed Dropbox place/folder! The simplest upload command would be:
dropbox_file upload <your local file> ""
dropbox_file upload img.jpg app_folder_dropbox
So, the pointed file would be upload to your home root. If you replace the empty string at the end with some Dropbox folder, then the file will be placed there. Exact syntax can be seen using:
dropbox_file --help
If you mean ready application to sync, yes, there is too. Take a look here.
pkd
3 years agoExplorer | Level 3
Good God, this seems so overly complicated. It's literally 10 lines of code for S3.
I think I'll use some other service instead of Dropbox.
- Greg-DB3 years ago
Dropbox Community Moderator
pkd I see Здравко helpfully shared a more fully-featured script, but much like what you originally shared, it is possible to upload to Dropbox using the API automatically once you process the authorization flow (which only needs to be done once) with minimal code.
The minimal usage to upload/overwrite a file over extended periods of time would look like this: (using credentials acquired using PKCE, like in Здравко's example)
import dropbox dbx = dropbox.Dropbox(oauth2_refresh_token="REFRESHTOKENHERE", app_key="APPKEYHERE") print(dbx.files_upload(b"some data here", "/upload_path/file.ext", mode=dropbox.files.WriteMode("overwrite")))- pkd3 years agoExplorer | Level 3
I chose "Allow public clients (Implicit Grant & PKCE)" in Settings but still there's no refresh token. Is it even possible to set this whole thing up using web interface at Dropbox?
- Здравко3 years agoLegendary | Level 20
pkd, Did you get some error or something? 🧐 The refresh token gets in the configuration file (on OAuth flow success) and stay there, where it's read on command start. The file gets updated whenever needed to minimize needed refreshes. Take a look in the configuration file (named 'cert.json', in my script, residing in 'dropbox_file' configuration folder) to take refresh token and use somewhere else if you want to (or copy the entire file). The configuration folder can be found in the standard place for configuration data according your platform. As Greg mentioned the refresh token, once received, can be used in very simplistic scripts without further user authentication. Don't forget to set the needed permissions/scopes, matching to your needs or add the needed as soon as you get error that they're missing (and receive the refresh token anew, such a change is NOT retroactive).
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!