简体   繁体   中英

Incomplete list of parents using Google Drive API

I'm looking to develop a web application using Google Drive API but I'm facing problems retrieving parents information about a file.

I have a file called "File 1-1-1" that correspond to this path/tree structure :

"/Folder 1/Folder 1-1/File 1-1-1"

Let's say this file has the ID "1234".

When I ping Google API such as " https://www.googleapis.com/drive/v2/files/1234/parents ", all I get is this :

{
  'kind' : 'drive#parentList',
  'etag' : etag,
  'selfLink' : selfLink,
  'items' : [
  {
    'kind' : 'drive#parentReference',
    'id' : '123', // ID of Folder 1-1
    'selfLink' : selfLink,
    'parentLink' : parentLink,
    'isRoot' : false
  }]
}

And that's it!!!

No reference to Folder 1!!

If I keep getting deeper in the tree structure, I have the same problem : only one parent is returned.

Is there anything I'm doing wrong?

Thanks for your help.

Cheers.

EDIT 1 :

I've already seen this question Google Drive API (PHP): some files missing parent reference but my files/folders are not shared so that's not the answer unfortunately...

Parents returns the direct parent(s), not all ascendents. Folder 1 is the parent of Folder 1-1, not of File 1-1-1. To get all ascendents you need to walk the tree.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM