Search Dropbox or Google Drive by File Hash or Fil

2019-09-03 02:10发布

问题:

I'm looking for a way to synchronize an archive of photos with an archive stored on Google Drive or Dropbox. One of the things that I need to do is to be able to rapidly determine if a given photo has already been uploaded to the remote file system.

The ideal way to do this would be to search by file hash, but looking at the APIs, I can't see an easy way to do that. Dropbox does allow you to walk the user's Dropbox and download metadata (which appears to include an MD5 hash).

Is there a better way?

回答1:

The Dropbox API now offers a hash of file data that you can use to verify a file's contents. You can find it in FileMetadata.content_hash. It isn't a single MD5 or SHA1, but rather a combination of SHA256 hashes of the pieces of the file. You can find more information here:

https://www.dropbox.com/developers/reference/content-hash

The API doesn't offer a way to search by this hash, but you can download the file metadata with it, and refer to it locally.