通过IOS Google Drive SDK列出Google云端硬盘的所有文件夹 [英] Listing of all folders of Google Drive through IOS Google Drive SDK

查看:348
本文介绍了通过IOS Google Drive SDK列出Google云端硬盘的所有文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我将google-drive-sdk与我的ios应用程序集成在一起。我可以通过google-drive-sdk for iOS在谷歌驱动器上传指定的文件。另外,我想提供一个功能,用于从用户希望在Google云端硬盘上传该文件的可用文件夹中选择文件夹。

Actually I integrated google-drive-sdk with my ios app. I can able to to upload specified file on google drive through google-drive-sdk for iOS. Additionally I want to provide a functionality for choosing a folder from available folder in which user want to upload that file on Google Drive.

所以,我找到了如何列出所有文件Google云端硬盘但无法找到如何列出Google云端硬盘的所有文件夹。

So, I found how to list all files of Google Drive but unable to find how to list of all folders of Google Drive.

我还浏览了整个 API参考,但没有找到任何解决方案。

I also went through whole API reference on Google Developer site but didn't found any solution about it.

我找到了一个使用下面的代码文件夹列表可以完成的地方,所以试了但是它没有用。

I had found somewhere that using below code folder listing can be done so tried it but it didn't work.

GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
query.q = @"mimeType='application/vnd.google-apps.folder' and trashed=false";

[self.driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
                                                          GTLDriveFileList *files,
                                                          NSError *error) {

    if (error == nil) {
        NSLog(@"Array of folder: %@", files.items);
    } else {
        NSLog(@"An error occurred: %@", error);
    }
}];

那么是否有任何解决方案可以使用google-drive-sdk从Google云端硬盘获取文件夹列表?

So is there any solution for getting list of folders from Google Drive using google-drive-sdk?

推荐答案

假设此代码有效,则查询中存在问题。多个查询应由组合。

Assuming this code works, there is a problem in the query. Multiple queries should be combined by and.

query.q = @"mimeType='application/vnd.google-apps.folder' and trashed=false";

有关示例查询的更多示例,请查看搜索文件

For more examples of sample queries, take a look at Search for Files in official documentation.

此外,如果此代码不存在无效,你想用 Files.list()查询以上。检查链接,您可能想要使用Object-c的示例代码。

Also, in case this code doesn't work, you want to use Files.list() with query above. Check the link and there is a sample code for Object-c you might want to use.

这篇关于通过IOS Google Drive SDK列出Google云端硬盘的所有文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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