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

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

问题描述

我在Google云端硬盘上收集了一些数据,这些数据以文件夹的形式组织,我想在其他服务器上进行传播。我有一些传播的脚本,但我需要从谷歌驱动器下载数据。有没有一种通过Google Drive API下载文件夹的方法,也就是保持整个文件夹结构? 解决方案

文件夹也是文件Google云端硬盘。唯一的区别是Mime类型。其文件夹为 mimeType ='application / vnd.google-apps.folder'

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

从评论中更新您需要循环访问每个目录,或者只是在您的驱动器帐户上做一切主要列表并在本地处理数据。


文件1(文件夹)

---->文件2(文件夹)

-------->文件3(实际上是文件)

---->文件四(实际上是一个文件)




 父母中的'文件1'

返回文件1目录中的所有内容。如果返回的项目的MIME类型是一个目录(mimeType ='application / vnd.google-apps.folder')请求获得它的可信度


'父母的文件2'

返回所有内容文件2目录。


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?

解决方案

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

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.

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

'File 1' in parents 

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

'File 2' in parents

returns everything within the file 2 directory.

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

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