List all Google Drive folders through the iOS Google Drive SDK

In fact, I integrated google-drive-sdk with my iOS app. I can upload the specified file to Google Drive via google-drive-sdk for iOS. In addition, I want to provide functionality for selecting a folder from an accessible folder in which the user wants to download this file to Google Drive.

So, I found how to list all the files in Google Drive, but could not find a list of all the folders in Google Drive.

I also looked at the whole API link on the Google Developer site, but could not find a solution to this.

I found somewhere that using the folder folder below, you can do this, but that 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 a solution for getting a list of folders from Google Drive using google-drive-sdk?

+5
source share
3 answers

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

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

For more sample query examples, see Finding Files in the Official Documentation.

Also, if this code does not work, you want to use Files.list () with the request above. Check the link and there is sample code for Object-c that you might want to use.

+2
source

What are the areas of action you are using? make sure you use

kGTLAuthScopeDrive = @ " https://www.googleapis.com/auth/drive ";

Example:

 NSString *scope = kGTLAuthScopeDrive; GTMOAuth2ViewControllerTouch *authViewController = [[GTMOAuth2ViewControllerTouch alloc] initWithScope:scope clientID:kClientId clientSecret:kClientSecret keychainItemName:kKeychainItemName delegate:self finishedSelector:finishedSelector]; [self presentViewController:authViewController animated:YES completion:nil]; 
+1
source

Use the correct area.

limited area drive.file, which allows you to only access the files created by him or open a user with it.

an all-wheel drive area that allows an application to manage all files on a user's disk.

It is highly recommended that you request a limited scope when possible. For more information about all available areas, see the Google Drive SDK documentation:

https://developers.google.com/drive/scopes

0
source

All Articles