Reputation: 63
I'm still learning the ins and outs of the Google Drive API. I'm trying to create a file browser for it that displays items in a hierarchical structure rather than displaying all files listed regardless of its parent.
The problem I came across was that there were some files with empty parents arrays. The idea is initially that it should show all files that exist in root, and only root, and then when a folder is clicked show its children.
However, the missing parent data has confused me.
Is this because those files have been shared with me and therefore do not have a parent reference in relation to me? If so, how can I identify such files? Using empty() on the returned parent data does not seem to recognise it as an empty array.
Upvotes: 3
Views: 1180
Reputation: 22306
I did a quick test and I get the same results. It makes sense that you should not be given any visibility of the parents of a shared file.
To know if a file is shared, look at the userPermission array.
Owned...
"userPermission": {
"kind": "drive#permission",
"id": "me",
"role": "owner",
"type": "user"
},
Shared...
"userPermission": {
"kind": "drive#permission",
"id": "me",
"role": "writer",
"type": "user"
},
Upvotes: 1