使用 Google Drive API 下载文件夹 [英] Download folder with Google Drive API

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

问题描述

我在 Google Drive 上有一些数据,按文件夹组织,我想在其他服务器上传播这些数据.我有一些用于传播的脚本,但我需要从谷歌驱动器下载数据.有没有一种通过 Google Drive API 下载文件夹的方法,同时保持整个文件夹结构?

I have some data on Google Drive, organized in folders, which I want to propagate on other servers. I have some script for propagating, but I need to download data from google drive. Is there a method for downloading folders via Google Drive API, that is also maintaining whole folder structure?

推荐答案

文件夹也是 Google Drive 上的文件.唯一的区别是 Mime 类型.与文件夹其 mimeType = 'application/vnd.google-apps.folder'.

Folders are also files on Google Drive. The only difference is the Mime type. with folders its mimeType = 'application/vnd.google-apps.folder'.

没有一种方法可以让您下载文件夹中的所有内容.您将不得不执行 file.list 搜索文件使用搜索参数将父 ID 添加到父文件夹的文件 ID(提示:''1234567' 在父母').这将返回文件夹中包含的文件列表.然后下载每一个.

There is no single method that will allow you to download everything with in a folder. Your going to have to do a file.list searching for the files with the parent Id to the file Id of your parent folder using search parameters (TIP: ''1234567' in parents'). This will return a list of the files contained within your folder. Then download each one.

从评论更新,您需要遍历每个目录,或者只列出驱动器帐户上所有内容的主列表并在本地处理数据.

Update from comment you need to loop though each directory or just do a main list of everything on your drive account and process the data locally.

文件 1(文件夹)
----> 文件 2(文件夹)
--------> 文件 3(实际上是一个文件)
---->文件四(其实是一个文件)

File 1 (folder)
----> File 2 (folder )
--------> File 3 (actually a file)
---->File Four (actually a file)

'File 1' in parents 

返回文件 1 目录中的所有内容.如果返回的项目的 mime 类型是目录 (mimeType = 'application/vnd.google-apps.folder') 请求获取其内容

returns everything within the file 1 directory. If the mime type of the item returned is a directory (mimeType = 'application/vnd.google-apps.folder') make a request to get its contences

父母中的文件2"

返回文件 2 目录中的所有内容.

returns everything within the file 2 directory.

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

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