Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

objective c list files from google drive

Am developing ios app including google drive. In google drive when am trying to list files, it displays all folders, subfolders, subfiles in single page itself. These is my code

GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];

    [driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
                                                         GTLDriveFileList *filesList,
                                                         NSError *error) {
if (error == nil) {

            [FilesFromGoogleDrive addObjectsFromArray:filesList.items
             ];

        };

I dont want to list all files in main page. I need similar to google drive application for accessing folders, subfolders, subfiles in sequential way.Am trying this from past one week but there is no good result. So please help me how to access folders, subfolders.

like image 303
Asokan R Avatar asked Jan 28 '13 12:01

Asokan R


People also ask

How do I get a list of files in Google Drive?

Goto the same Google Sheets File and refresh the page. Then you will get the "List Files/Folders" menu, click on it, and select the "List All Files and Folders" item.

How do I move files from Google Drive to C drive?

Create a folder, or folders, in your Google Drive that you want to move your C drive documents into. Now, it's as simple as click and drag the documents you want to transfer from your computer to your Google Drive and drop them in.

How do I list files by size in Google Drive?

At drive.google.com, click on Storage, near the bottom of the left-hand sidebar (or click here to visit directly). From the Storage page, you can see a list of your files sorted by size, largest first. Delete any unnecessary files and remove them from the Trash in order to lower your used space.


1 Answers

If you want to list all files in a folder identified by folderId, you can use the following code (from https://developers.google.com/drive/v2/reference/children/list):

+ (void)printFilesInFolderWithService:(GTLServiceDrive *)service
                             folderId:(NSString *)folderId {
  // The service can be set to automatically fetch all pages of the result. More
  // information can be found on https://code.google.com/p/google-api-objectivec-client/wiki/Introduction#Result_Pages.
  service.shouldFetchNextPages = YES;

  GTLQueryDrive *query =
    [GTLQueryDrive queryForChildrenListWithFolderId:folderId];
  // queryTicket can be used to track the status of the request.
  GTLServiceTicket *queryTicket =
    [service executeQuery:query
        completionHandler:^(GTLServiceTicket *ticket,
                            GTLDriveChildList *children, NSError *error) {
          if (error == nil) {
            for (GTLDriveChildReference *child in children) {
              NSLog(@"File Id: %@", child.identifier);
            }
          } else {
            NSLog(@"An error occurred: %@", error);
          }
        }];
}

Another option is to search for files having folderId in their Parents collection:

https://developers.google.com/drive/search-parameters

For instance, you can have a search query like the following:

'1234567' in parents

Where '1234567' is the id of the folder you want to list files for.

like image 94
Claudio Cherubino Avatar answered Sep 22 '22 00:09

Claudio Cherubino