question

brittle81 avatar image
brittle81 asked

Changes API

I've read all the documentation for changes API and still can't figure out how to use it. Suppose I want to check for changes since some checkpoint. To do this, I need some starting checkpoint, that corresponds to "now". If I send POST without any checkpoint it looks that I end up fetching all the history from the "beginning of time", which takes forever. On Google Drive, for example, an account has "largestChangeId", which is a big number, monotonically increasing. If largestChangeId has gone up since the last time we've seen it then there are some changes and I can get list of changes that happened since given change ID. On Cloud Drive we have "checkpoints" that are opaque strings, with no order defined and no easy way to get "checkpoint" that corresponds to "now".
amazon drive
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

yadayada avatar image
yadayada answered
You need to get the full change set one time. The ID of the last line of changes prior to the end marker line is your new "now" checkpoint that you can use as reference checkpoint next time.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

hitlabs avatar image
hitlabs answered
I'd like to clarify the above response. The last data showing changed before the end segment shows as follows: "version": 11, "isShared": false, "createdDate": "2015-07-21T15:10:22.707Z", "modifiedDate": "2015-07-21T15:12:51.812Z", "eTagResponse": "V3TDDfIZHyI", "createdBy": "CloudDriveDesktop", "id": "34ybAOmDSJKmNiOevPAdqA", "parents": [ "0-tlUDpXQOmJ3A3x_YQXnA" ], "contentProperties": { "contentType": "video/3gpp", "extension": "3gp", "md5": "bb632336483fd0c07408455019d55f1e", "video": { "videoFrameRate": 30, "bitrate": 10166185, "creationDate": "2012-07-22T22:54:47.000Z", "videoBitrate": 10065610, "audioCodec": "aac", "rotate": 0, "duration": 45.915, "location": "+00.0000+000.0000/", "audioBitrate": 96131, "audioSampleRate": 44100, "videoCodec": "mpeg4", "height": 720, "audioChannels": 2, "width": 1280, "audioChannelLayout": "stereo" }, "contentDate": "2012-07-22T22:54:47.000Z", "size": 58347550, "version": 1 }, "restricted": false, "kind": "FILE", "labels": [], "status": "AVAILABLE", "name": "2012-07-22_16-54-16_291.3gp", "properties": { "CloudDrive": { "Processing": "VIDEO_PROCESSED" } } Is it safe to assume then my checkpoint would be 34ybAOmDSJKmNiOevPAdqA (the ID of the above)? I've added several items since getting this changes set and have tried calling the changes API again by using the following: https://cdws.us-east-1.amazonaws.com/drive/v1/changes?checkpoint=34ybAOmDSJKmNiOevPAdqA I get the full changes history again. Not everything after the above ID. Am I doing something wrong?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

hitlabs avatar image
hitlabs answered
*** Update *** I was able to figure this out. I didn't realize that the checkpoint had to be sent as a JSON object. Once I figured that out I was able to try the last ID method that yadayada mentions above. This did not work for me. Instead I sent back the checkpoint key returned at the top of the history JSON and it worked perfectly. Giving me all history after that checkpoint key.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brittle81 avatar image
brittle81 answered
Thanks for the explanations, I will try /changes again and will let you know how it goes.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.