查找文件的父级ID:Google Drive API V3 [英] Find file's parent id : Google Drive API V3

查看:159
本文介绍了查找文件的父级ID:Google Drive API V3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



今天我将Drive API升级到V3后,我找到了找到父级的方法所选文件。如果你有相关的文件的文件ID是否有问题,那么, 文件:获取您需要添加字段即父母和文件ID。



请求


GET
https://www.googleapis.com/drive/v3 / files / 0B5pJkOVaKccENWNNcFFaU2lSM0E?fields = parents& key = {YOUR_API_KEY}


返回


{parents:[0B5pJkOVaKccEYW5lVHBKd1Zwc28]}

实际上是一个文件ID。请记住文件和目录在Drive中是一样的。



再次执行files.get


GET
https://www.googleapis.com/drive / v3 / files / 0B5pJkOVaKccEYW5lVHBKd1Zwc28?key = {YOUR_API_KEY}


结果


{kind:drive#file,id:0B5pJkOVaKccEYW5lVHBKd1Zwc28,
name:SiteBackups,mimeType:
application / vnd.google-apps.folder}



Today after I updated my Drive API to V3, I dint find any method to find the parent of the selected file . Is the rest endpoint to fetch json related to parent's info changed?

解决方案

If you have the file id of the file in question then Files: get you need to add fields ie parents along with the file id.

Request

GET https://www.googleapis.com/drive/v3/files/0B5pJkOVaKccENWNNcFFaU2lSM0E?fields=parents&key={YOUR_API_KEY}

Returns

{ "parents": [ "0B5pJkOVaKccEYW5lVHBKd1Zwc28" ] }

The result is actually a file id. Remember files and directories are the same in Drive.

Do files.get again

GET https://www.googleapis.com/drive/v3/files/0B5pJkOVaKccEYW5lVHBKd1Zwc28?key={YOUR_API_KEY}

Results

{ "kind": "drive#file", "id": "0B5pJkOVaKccEYW5lVHBKd1Zwc28", "name": "SiteBackups", "mimeType": "application/vnd.google-apps.folder" }

这篇关于查找文件的父级ID:Google Drive API V3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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