查找文件的父 ID:Google Drive API V3 [英] Find file's parent id : Google Drive API V3
问题描述
今天在我将 Drive API 更新到 V3 后,我找不到任何方法来查找所选文件的父级.获取与父信息相关的 json 的其余端点是否已更改?
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?
推荐答案
如果您有相关文件的文件 ID,则 文件:获取您需要添加字段,即父项以及文件 ID.
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.
请求
获取https://www.googleapis.com/drive/v3/files/0B5pJkOVaKccENWNNcFFaU2lSM0E?fields=parents&key={YOUR_API_KEY}
GET https://www.googleapis.com/drive/v3/files/0B5pJkOVaKccENWNNcFFaU2lSM0E?fields=parents&key={YOUR_API_KEY}
退货
{ "父母": [ "0B5pJkOVaKccEYW5lVHBKd1Zwc28"] }
{ "parents": [ "0B5pJkOVaKccEYW5lVHBKd1Zwc28" ] }
结果实际上是一个文件 id.请记住,云端硬盘中的文件和目录是相同的.
The result is actually a file id. Remember files and directories are the same in Drive.
重新获取文件
获取https://www.googleapis.com/drive/v3/files/0B5pJkOVaKccEYW5lVHBKd1Z?key={YOUR_API_KEY}
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" }
{ "kind": "drive#file", "id": "0B5pJkOVaKccEYW5lVHBKd1Zwc28", "name": "SiteBackups", "mimeType": "application/vnd.google-apps.folder" }
这篇关于查找文件的父 ID:Google Drive API V3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!