sunil
sunil

Reputation: 300

How can we get only folders and pdf files from google drive ios

This is my code for getting pdf files and folders .

 GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
 query.q = @"mimeType = 'application/pdf' and mimeType ='text/directory' and mimeType='application/vnd.google-apps.folder'";

// executing Query .

GTLDriveFile * file =[self.driveFiles objectAtIndex:i];
NSString * str = file.title;
NSString * strExtension = @"pdf";
if ([[str pathExtension]isEqualToString:@""]||[[[str pathExtension]lowercaseString]isEqualToString:strExtension])
 {
// adding to array . [pdf files and folders]
 }

Here my problem is ., If a pdf file is there in google drive,in the name itself showing the extension name.pdf .,So Pdf is fine. For getting folders also fine but for some files like doc saved without any extension in title, it is also displaying as a folder. How to get the type , whether it is a folder or file .

Upvotes: 1

Views: 693

Answers (1)

sunil
sunil

Reputation: 300

GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
query.q = @"mimeType = 'application/pdf' and mimeType='application/vnd.google-apps.folder'";

// executing Query .

GTLDriveFile * file =[self.driveFiles objectAtIndex:i];
NSString * str = file.mimeType;
if ([str isEqualToString:@"application/pdf"]||[str isEqualToString:@"application/vnd.google-apps.folder"])
 {
// adding to array . [pdf files and folders]
 }

Upvotes: 1

Related Questions