如何在 Google Drive API 上按文件夹获取文件列表 [英] How to get list of files by folder on Google Drive API

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

问题描述

我正在尝试构建一个网络用户界面,供用户浏览他/她的 Google 云端硬盘并选择一个或多个文档,以便稍后在网站中从数据库中引用.我目前正在使用 .NET 构建 Web 界面.我面临的问题是我找不到一个函数来按文件夹 ID 获取文件列表.我尝试使用:

I am trying to build a web UI for users to navigate his/her Google Drive and select one or more documents to be referenced later on in a website from a DB. I am currently building a web interface using .NET. The problem I am facing is that I can not find a single function to get a list of files by folder Id. I tried using:

...www.googleapis.com/drive/v2/files/BB0CHANGEDIDF5waGdzbUQ5aWs/children

...但这只会给出文件夹中文件的文件引用 ID(所谓的子资源项),这意味着我必须遍历这些文件并为每个文件创建一个调用才能获取我的 UI 所需的所有元数据.不幸的是..

…but that will only give the files reference ID of the files within the folder (the so called children resource item), which means I have to loop through those files and create a call for each one of them in order to get all the metadata I need for my UI. Unfortunately..

...www.googleapis.com/drive/v2/files

..将列出我所有的文件,没有按文件夹过滤选项.我想知道是否有一种有效的方法来提取文件夹&来自特定文件夹的单个调用驱动器服务器的文件列表.

..will list ALL my files with no filtering options by folder. I would like to know if there is an efficient way of extracting a folder& file list from a single call to the Drive server by for a specific folder.

我也试过这个(基于对类似问题的回答):我正在使用 Fiddler 直接调用 api.当我用它来拨打电话时`

I also tried this (based on answer to the similar issue): I am using Fiddler to do direct calls to the api. When I use this to make the call `

...www.googleapis.com/drive/v2/files?q='BB0CHANGEDIDF5waGdzbUQ5aWs'

我得到一个错误:

{
 "error": {
  "errors": [
   {wrongID
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value",
    "locationType": "parameter",
    "location": "q"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }
}

即使使用 google 的测试页 也不行.看起来文件"端点不接受任何参数.

Even using google's test page does not do it. It looks like the "files" endpoint does not accept any parameter.

必须有一种方法来实现这一点!

There has to be a way to achieve this!

感谢您的帮助

推荐答案

你应该可以简单地使用 文件/列表 带有父查询;

You should be able to simply use files/list with a parent query;

GET https://www.googleapis.com/drive/v2/files?q='BB0CHANGEDIDF5waGdzbUQ5aWs'+in+parents&key={YOUR_API_KEY}

这篇关于如何在 Google Drive API 上按文件夹获取文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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