为什么使用Google Cloud Drive Rest API file.list无法获取所有文件?

时间:2018-12-01 11:14:17

标签: rest sdk google-drive-api google-drive-android-api drive

我正在使用以下CURL命令来检索我所有的Google驱动器文件,但是,它只列出了整个文件中非常有限的一部分。为什么?

curl -H "Authorization: Bearer ya29.hereshouldbethemaskedaccesstokenvalue" https://www.googleapis.com/drive/v3/files

结果

{
"kind": "drive#fileList",
"incompleteSearch": false,
"files": [
{
"kind": "drive#file",
id": "2fileidxxxxxxxx",
"name": "testnum",
"mimeType": "application/vnd.google-apps.folder"
},
{
"kind": "drive#file",
"id": "1fileidxxxxxxx",
"name": "test2.txt",
...
}

令牌范围包括   https://www.googleapis.com/auth/drive.file   https://www.googleapis.com/auth/drive.appdata

使用Android SDK也会遇到相同的问题。

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

files.list的结果是分页的-您的响应应包含“ nextPageToken”字段,并且您将不得不再次调用下一页结果。有关文件列表调用,请参见文档here。您可能要使用一个客户端库进行此调用(请参阅页面底部的示例)