Google Drive API - Changes: list. Retrieving the original identifier of a remote file
When trying to discover deleted objects using the Changes: List ribbon, I noticed that the value was id
incorrect, preventing me from determining which file was deleted. Example:
Create a new test file: this is a test file
public 'title' => string 'This is a test' (length=14)
public 'id' => string '1wUFHe3DfU1mJnyqlIgAYSvMrIy8F91-7rZyAPFsyVpg' (length=44)
Now when I delete this file, the first entry for the remote change is:
public 'deleted' => boolean true
protected 'fileType' => string 'Google_Service_Drive_DriveFile' (length=30)
protected 'fileDataType' => string '' (length=0)
public 'fileId' => string '1_8Cvirw71AY0HQoaNwSMP3TlcIFAhpZikVfOrXFZCLo' (length=44)
public 'id' => string '3612' (length=4)
public 'kind' => string 'drive#change' (length=12)
public 'modificationDate' => string '2013-12-23T10:55:45.340Z' (length=24)
public 'selfLink' => string 'https://www.googleapis.com/drive/v2/changes/3612' (length=48)
protected 'modelData' =>
array (size=0)
empty
protected 'processed' =>
array (size=0)
empty
None of the identifiers ( fileId
and id
) is not id
a file "This is a test file." I read in the API documentation that the results are displayed from bottom to top, but not the deleted changes contain my original file ID.
How do I know which file has been deleted?
EDIT: I created a video showing my problems, steps
- I create a new file (just before the start of the video)
- I will show its ID in the "Changes:"
- I am deleting this file
- I am creating another file
- I will show the file ID in the "Changes:"
- The Changes: list shows my first file ID and immediately after that the second generated file ID. It doesn't show deleting file event
https://www.youtube.com/watch?v=hh2ARFdxWGk
Sorry for the poor quality, I used a bad screen recorder
source to share
Instead of making changes, you can try using the Application Activity API . I just tested with the app activity API and both garbage and emptyTrash show both events. The API Explorer gives you an idea of how to achieve this.
source to share
First, the change feed entries are sorted in ascending chronological order. That is, the oldest changes appear first. So check out the latest curls in the answer.
You can also try this in the API . Get the first set of lists and for getting the latest changes you can either get nextPageToken
from the response or largestChangeId
from the last change in the list and get the next set of changes.
Hope it helps!
source to share