2

How does the etag of a File Resource works? It looks like it's changing even if no change is made on the file.

Is there a way to get a checksum or something that change only when the file is updated?

Thanks for your help!

Martin
  • 2,290
  • 1
  • 23
  • 28

1 Answers1

4

The Etag of a file also changes when the file's metadata changes. If you want to only monitor changes to the file's content, you can use the md5Checksum field instead:

https://developers.google.com/drive/v2/reference/files#resource

Claudio Cherubino
  • 14,896
  • 1
  • 35
  • 42
  • 1
    @Claudio Despite it says *"An MD5 checksum for the content of this file. This will only be populated on files with content stored in Drive."* [in the docs](https://developers.google.com/resources/api-libraries/documentation/drive/v1/java/latest/com/google/api/services/drive/model/File.html#getMd5Checksum()), I get `null` MD5 checksum. However, ETag contains a valid value. My file is stored in Drive. Can you explain this? – Juuso Ohtonen Mar 29 '14 at 08:58
  • 3
    It is because content of Your file doesn't stored in drive, e.g. Google Doc. I can't find a proof link, but I read some time ago on Google pages that documents, spreadsheets, drawings content is not a part of Google Drive. – Nicolai Jul 30 '14 at 19:38
  • 1
    I don't see ETag in [v3](https://developers.google.com/drive/v3/reference/files#resource). What to use for "if-match" header to detect conflict in v3? – surlac Dec 13 '16 at 22:33