cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Upload API - skip upload, when file with the same content already uploaded

Upload API - skip upload, when file with the same content already uploaded

jijik
New member | Level 2
Go to solution

Dropbox windows app is smart and when currently uploading file already exists somewhere in dropbox (file with the same content hash I guess), it doesn't fully upload it again. It gets marked as uploaded almost immediately. Is it possible to achieve such optimization via the Dropbox Upload API? I use UploadSessionStartAsync APi, but it always fully upload any file even if the file already exists in neighbor directory.

Thank you

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

The Dropbox API doesn't offer a way to do this automatically, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.

 

You could effectively reproduce this behavior though, at least within an account. To do, you'd need to do something like this:

  • Use /2/files/list_folder[/continue] to list the metadata for the contents of the account, which includes the 'content_hash' for each file. (You can cache this and update it over time as needed.)
  • Before starting an upload of a file, compute the content hash of the local data.
  • Check if that local content hash exists in the account already, by looking for it in the metadata retrieved in the first step.
  • If the content_hash is found in the existing metadata, use /2/files/copy_v2 to copy the existing file to the new path instead of uploading it again. If it is not found, proceed to upload it normally (e.g., using UploadSessionStartAsync, etc.).

View solution in original post

1 Reply 1

Greg-DB
Dropbox Staff
Go to solution

The Dropbox API doesn't offer a way to do this automatically, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.

 

You could effectively reproduce this behavior though, at least within an account. To do, you'd need to do something like this:

  • Use /2/files/list_folder[/continue] to list the metadata for the contents of the account, which includes the 'content_hash' for each file. (You can cache this and update it over time as needed.)
  • Before starting an upload of a file, compute the content hash of the local data.
  • Check if that local content hash exists in the account already, by looking for it in the metadata retrieved in the first step.
  • If the content_hash is found in the existing metadata, use /2/files/copy_v2 to copy the existing file to the new path instead of uploading it again. If it is not found, proceed to upload it normally (e.g., using UploadSessionStartAsync, etc.).
Need more support?
Who's talking

Top contributors to this post

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