Google Drive API(PHP):某些文件缺少父引用 [英] Google Drive API (PHP): some files missing parent reference

查看:102
本文介绍了Google Drive API(PHP):某些文件缺少父引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍在学习Google Drive API的来龙去脉。我试图为它创建一个文件浏览器,以层次结构的形式显示项目,而不是显示列出的所有文件,无论其父项如何。



我碰到的问题是有一些空父母数组的文件。这个想法最初是它应该显示所有存在于根目录下的文件,并且只显示根目录,然后当文件夹被点击时显示其子目录。



但是,数据混淆了我。



这是因为这些文件已经与我共享,因此没有与我有关的父亲引用?如果是这样,我如何识别这些文件?对返回的父数据使用empty()似乎并不认为它是一个空数组。

解决方案

我做了一个快速测试并得到相同的结果。
有意义的是,您不应该看到共享文件父母的任何可见性。



要知道文件是否共享,请查看userPermission数组。

拥有.. 。


$ b

 userPermission:{
kind:drive#permission,
id:me,
role:owner,
type:user
},


<$ c $ $ c>userPermission:{
kind:drive#permission,
id:me,
role:writer,
type:user
},


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.

解决方案

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"
   },

这篇关于Google Drive API(PHP):某些文件缺少父引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆