Listing All files and folders from Google Drive in DrEdit

后端 未结 1 1051
臣服心动
臣服心动 2021-01-03 09:21

I know this question has been (Listing All Folder content from Google Drive), but i didn\'t found answer. I have the same problem. If i uploaded file to the google drive i c

相关标签:
1条回答
  • 2021-01-03 10:01

    If, you want to list all files and folders from google drive, use this method.

    -(void)loadDriveFiles
    {
    GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
    query.q = [NSString stringWithFormat:@"'%@' IN parents", @"root"];
    [self.driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
                                                          GTLDriveFileList *files,
                                                          NSError *error) {
        if (error == nil)
        {
            driveFiles = [[NSMutableArray alloc] init]; // 
            [driveFiles addObjectsFromArray:files.items];
    
            for (GTLDriveFile *file in driveFiles)
                 NSLog(@"File is %@", file.title);
        }
        else
        {
            NSLog(@"An error occurred: %@", error);
        }
    }];
    }
    

    For Mime types refer this, and use it in query using or operator.

    example- GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
    query.q = @" mimeType ='audio/mpeg' or mimeType ='audio/wav' or mimeType ='audio/aac' or mimeType ='audio/aiff'  or mimeType = 'video/mp4'  or mimeType = 'image/png' or mimeType = 'application/zip' ";
    

    Mime Types available-

    $mime_types= array(
                    "xls" =>'application/vnd.ms-excel',
                    "xlsx" =>'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                    "xml" =>'text/xml',
                    "ods"=>'application/vnd.oasis.opendocument.spreadsheet',
                    "csv"=>'text/plain',
                    "tmpl"=>'text/plain',
                    "pdf"=> 'application/pdf',
                    "php"=>'application/x-httpd-php',
                    "jpg"=>'image/jpeg',
                    "png"=>'image/png',
                    "gif"=>'image/gif',
                    "bmp"=>'image/bmp',
                    "txt"=>'text/plain',
                    "doc"=>'application/msword',
                    "js"=>'text/js',
                    "swf"=>'application/x-shockwave-flash',
                    "mp3"=>'audio/mpeg',
                    "zip"=>'application/zip',
                    "rar"=>'application/rar',
                    "tar"=>'application/tar',
                    "arj"=>'application/arj',
                    "cab"=>'application/cab',
                    "html"=>'text/html',
                    "htm"=>'text/html',
                    "default"=>'application/octet-stream',
                    "folder"=>'application/vnd.google-apps.folder'
                                           );
    
    0 讨论(0)
提交回复
热议问题