cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Will uploading a bunch of files that are mostly already present overwrite them, or skip them?

Will uploading a bunch of files that are mostly already present overwrite them, or skip them?

FlyingThunder
Explorer | Level 3

This is my case:

 

I have a discord bot that saves a bunch of mp3s that it downloads via YoutubeDL from user input. Because the hoster resets daily, these files would only be temporary on the hoster. To solve this i am using the Python Library for the Dropbox API.

Every time the bot starts, i tell it to download all the files in a specified Dropbox Folder, and heres where my problem lies:

Because i the restarts of the hosters arent always at a set time, i want the bot to upload (aka backup) the files as soon as a new file is added. For simplicity, i would just tell it to upload all the files in the folder, but before i do this i want to make sure - will this result in the bot uploading EVERY FILE and overwriting the old, identical ones, or will the API see that a file is already present, and skip it - ideally with a catchable error? If the first is the case i will have to add code to compare the Dropbox files to the local ones, but if its the later i can save my time and just throw all the files at it.

 

I tested it and the "modified" timestamp didnt change for the identical files, but the script took kinda long so i wanna be sure

1 Reply 1

Greg-DB
Dropbox Staff

Exactly what would happen if you use the Dropbox API upload functionality to upload files to paths that already exist will depend on the particular parameters you use when uploading. You can find information on the different parameters and the behaviors they will yield in the documentation, such as for the /2/files/upload endpoint, which is files_upload in the official Dropbox API v2 Python SDK.

 

By default though, that is, if you don't specify any non-default parameter values, uploading a file to a path that already contains a file with the exact same contents as the upload will essentially be a "no-op". The call will be returned successful, but nothing will be changed in the Dropbox folder. 

 

Note that in any case though, the Dropbox API servers have to receive the entire upload before they can check if the contents are identical, so doing that every time will consume extra bandwidth. To avoid that, you can instead use the API to check if the file exists ahead of time, and even check the contents without uploading or downloading them first. For example, you can use the /2/files/get_metadata endpointfiles_get_metadata in the Dropbox Python SDK, to get the metadata for the file, and compute and compare the content hash.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?