Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I query Google Drive for id of a folder with known name in root folder (Google Drive SDK for iPhone)?

With query

GTLQueryDrive *queryFilesList = [GTLQueryDrive queryForChildrenListWithFolderId:@"root"];

I get everything in root folder: files and folders. Sure, I can look for folder in GTLDriveChildList returned. But root folder can have thousands items, and I need only one of them. I tried narrow search. Comments in GTLQueryDrive.h say it's possible. I've tried

queryFilesList.q = @"mimeType='application/vnd.google-apps.folder'";

to query only folders or

queryFilesList.q = [NSString stringWithFormat:@"title='%@'", folderName];

to query all items by name. Both queries return empty lists. Double checked: folder I look for really exists.

I've tried

GTLQueryDrive *queryFilesList = [GTLQueryDrive queryForFilesList];

It works well with

queryFilesList.q =  @"mimeType='audio/x-aiff'";

But returns empty list if I try to query only folders with

queryFilesList.q =  @"mimeType='application/vnd.google-apps.folder'";

What am I doing wrong?

like image 432
Valeriy Van Avatar asked Apr 01 '13 19:04

Valeriy Van


1 Answers

I am selfish idiot!

GTLQueryDrive *queryFilesList = [GTLQueryDrive queryForChildrenListWithFolderId:@"root"];
queryFilesList.q = @"mimeType='application/vnd.google-apps.folder'";

works just fine, but it sees ONLY folders created with this app! That was my problem. To be exact you may use this query:

queryFilesList.q = @"mimeType='application/vnd.google-apps.folder' and 'root' in parents and trashed=false";

trashed=false is important if you don't want trashed items to be found.

like image 141
Valeriy Van Avatar answered Oct 20 '22 23:10

Valeriy Van