Google Drive API - 列出文件夹中的文件 [英] Google Drive API - list files in folder

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

问题描述

如同可能的开发者一样,我想获得特定文件夹中所有文件的列表。
我有以下基本的树形结构

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $


test1.doc
test2.doc
logs
resultsA.csv
resultsB.csv

尝试列出root / swimmer / trainings中的文件,我尝试使用:

  GET https ://www.googleapis.com/drive/v2/files/trainings/children 

并测试了它在 https://developers.google.com/drive/v2/reference/children/中列表



但我得到了404响应:

  404未找到
- 显示标题 -
{
错误:{
错误:[
{
domain:global ,
reason:notFound,
message:File not found:trainings
}
],
code:404,
消息:未找到文件:培训
}
}

我也试过了:GET https://www.googleapis.com/drive/v2/files?maxResults=10&projection = BASIC& q = 'trainings'+ in + parents& key = {YOUR_API_KEY}



找不到相同的结果..



我在哪里错了?

解决方案

仔细查阅文档。
在#1中,它不是文件夹名称,它的文件夹ID(或者你认为它会知道可能的几个文件夹名为'trainings')?

As may devs, I want to get a list of all files in a specific folder. I have the following basic tree structure

root
   swimmer
      trainings
         test1.doc
         test2.doc
      logs
         resultsA.csv
         resultsB.csv

trying to list files in root/swimmer/trainings , I tried to use :

 GET https://www.googleapis.com/drive/v2/files/trainings/children

and tested it within https://developers.google.com/drive/v2/reference/children/list

but I get the 404 response :

404 Not Found
- Show headers -
  {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "File not found: trainings"
   }
  ],
  "code": 404,
  "message": "File not found: trainings"
 }
}

I also tried : GET https://www.googleapis.com/drive/v2/files?maxResults=10&projection=BASIC&q='trainings'+in+parents&key={YOUR_API_KEY}

same result not found ..

where am I wrong ?

解决方案

Many things wrong in both your http urls. Look up the docs carefully. In #1 its not the folder name, its the folder id (or else how do you think it would know which of the possibly several folders named 'trainings' to use?)

这篇关于Google Drive API - 列出文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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