Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing of all folders of Google Drive through IOS Google Drive SDK

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.

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

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);
    }
}];

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

like image 762
Nirav Valera Avatar asked Oct 21 '22 07:10

Nirav Valera


1 Answers

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.

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.

like image 80
JunYoung Gwak Avatar answered Oct 24 '22 02:10

JunYoung Gwak