且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 Google Drive API 下载文件夹

更新时间:2023-02-14 12:51:33

文件夹也是 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.