Forum Discussion

Brian S.53's avatar
Brian S.53
Explorer | Level 3
9 years ago

How do you track when only a file's contents have changed (API v2)

How would I track when a file's contents have changed remotely?

 

I've seen the "rev" value, but this also increments when the file is moved/renamed, and I'd like to ignore any changes not related to the content changing.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The rev is currently the best way to track changes like this. If the rev hasn't changed, you know that the file contents have changed. If the rev has changed, the file contents may have changed.

    The rev does change when a file is moved or renamed though, as you mentioned. It sounds like you'd be better suited by a hash of the file contents. The Dropbox API doesn't currently offer files hashes like this, but I'll be sure to pass this along as a feature request. 

    • Greg-DB's avatar
      Greg-DB
      Icon for Dropbox Staff rankDropbox Staff
      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