(Note: This is a self-answering question)
我注意到orderBy
folder,title
非常慢,我该怎么办?
$ time curl 'https://content.googleapis.com/drive/v2/files?maxResults=10&orderBy=folder%2Ctitle&q=%27root%27%20in%20parents%20and%20trashed%3Dfalse&key=XXX' --compressed -H 'Authorization: Bearer XXX' -H 'X-Origin: https://explorer.apis.google.com' -H 'If-None-Match: "XXX"'
完成需要大约11秒钟:
real 0m11.356s
user 0m0.008s
sys 0m0.016s
你可以test in API Explorer。查询是:
答案 0 :(得分:-2)
<强> (Note: I'm self-answering my question) 强>
API v3正在运行,如果可能,请考虑从v2迁移。它将减少到<1秒(v2中的字段title
在v3中称为name
,而v2中的maxResults
在v3中称为pageSize
:
$ time curl 'https://content.googleapis.com/drive/v3/files?orderBy=folder%2Cname&pageSize=10&q=%27root%27%20in%20parents%20and%20trashed%3Dfalse&key=XXX' --compressed -H 'Authorization: Bearer XXX' -H 'X-Requested-With: XMLHttpRequest' -H 'X-Origin: https://explorer.apis.google.com'
...
real 0m0.674s
user 0m0.024s
sys 0m0.004s
在第3版中,您还需要指定fields
,例如(单击&#34;显示标准参数&#34;在&#34中扩展字段表单;试用它API资源管理器&#34;):
files(kind,id,name,size,mimeType,thumbnailLink)