curl - GoogleDrive API & Curl:如何只列出我自己的文件
问题描述
我想列出我在 Google Drive 中的所有文件(不是与我共享的文件,只有我自己的文件)。
我正在尝试使用什么:https ://developers.google.com/drive/api/v3/reference/files/list
我已经能够授予 OAuth、访问令牌和一切。
curl \
'https://www.googleapis.com/drive/v3/files?corpora=user&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
预期结果是我所有文件的列表,结果是与我共享的文件的部分列表。
解决方案
As you may see in the documentation of the endpoint, the call has an optional parameter called pageSize
. That parameter defines the amount of results you will get, and has a default value of 100.
- pageSize parameter (as in the documentation, November 7th 2019)
The maximum number of files to return per page. Partial or empty result pages are possible even before the end of the files list has been reached. Acceptable values are 1 to 1000, inclusive. (Default: 100)
In order to obtain all your results, in case that the amount is lower than 1000 you can just set that parameter to 1000 and obtain all the results. In case it is not, you will have to create a for loop and make several calls. You can see more on how to use pagination on Google APIs in this link.
推荐阅读
- multithreading - 在 Spring Batch 中使用自定义 TaskExecutor
- typescript - 打字稿中的递归类型别名 - 键入 flatten 函数
- typescript - 在 Firebase 云功能中发送推送通知时出错
- nrules - NRules 问题:超类的规则匹配不起作用
- android - 我的回收站视图不显示所有图像和文本它只显示最后一个图像和名称“arraylist.size”时间
- reactjs - 防止在 React 中连续单击按钮
- jenkins - Jenkins 声明式:触发另一个管道并将阶段结果传递给当前管道
- php - 如何在 Visual Studio Online / Codespaces 上安装 PHP
- flutter - 当 FCM 数据消息到达时启动处于终止或后台状态的颤振应用程序(仅在 android OS 中)
- python - 如何使用python解析网站的标题?