Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Drive API - Changes: list. Getting the original ID of a deleted file

When trying to detect deleted objects using the Changes: list feed, I noticed that the id value is incorrect making it impossible for me to detect which file was deleted. Example:

Make new testfile : 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 a deleted 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) equal the id from the file 'This is a test file'. I read in the API documentation that the results are from the bottom up, but non of the deleted changes contain my original file id.

How would I know which file was deleted?

EDIT: I've created a video showing my problems, steps

  • I create a new file (just before the video started)
  • I show it's ID in the Changes: list
  • I delete this file
  • I create another file
  • I show the file ID in the Changes: list
  • The Changes: list shows my first file ID and right after that the second created file ID. It doesn't show to delete file event

https://www.youtube.com/watch?v=hh2ARFdxWGk

Sorry for the poor quality, I used a bad screen recording tool

like image 728
Martijn Nosyncerror Avatar asked Sep 02 '25 07:09

Martijn Nosyncerror


1 Answers

You might try using the Apps Activity API instead of Changes. I just tested with Apps Activity API and both trash and emptyTrash show as events. The API Explorer gives you an idea of how to achieve this.

like image 163
Jay Lee Avatar answered Sep 04 '25 20:09

Jay Lee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!