Google Drive API - list specific files in a specific folder using Objective-C

前提是你 提交于 2019-12-06 06:05:50
Adarsh G J
-(void)fetchGoogleDriveFileListWithfolderId:(NSString *)folderId
    :(void (^)(NSMutableArray *, NSError*))completionBlock
{
    GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
    query.q =[NSString stringWithFormat:@"'%@' in parents and trashed=false", folderId];

    GTLServiceTicket *ticketListing = [self.driveService
        executeQuery:query completionHandler:^(GTLServiceTicket *ticket,GTLDriveFileList *files, NSError *error)
    {
        NSMutableArray *mainArray=[[NSMutableArray alloc]init];

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

You can use above method for fetch the folder contents. Here folderId is

  • “root” (Main Drive)
  • “sharedWithMe” for shared folder
  • GTLDrivefile identifier value
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!