IOS: How to uplaod a file to specific google drive folder using google drive sdk library
- by loganathan
I integrated google drive sdk with my ios app. But i do not know how to upload a file to google drive specific folder. Here the code am using to upload the file. But this one uploading the file to my google drive root folder. Any one share a code to upload a file to google drive specific folder?.
My Code:
-(void)uploadFileToGoogleDrive:(NSString*)fileName
{
GTLDriveFile *driveFile = [[[GTLDriveFile alloc]init] autorelease];
driveFile.mimeType = @"application/pdf";
driveFile.originalFilename = @"test.doc";
driveFile.title = @"test.doc";
NSString *filePath = [LocalFilesDetails getUserDocumentFullPathForFileName:fileName isSignedDocument:YES];
GTLUploadParameters *uploadParameters = [GTLUploadParameters
uploadParametersWithData:[NSData dataWithContentsOfFile:filePath]
MIMEType:@"application/pdf"];
GTLQueryDrive *query = [GTLQueryDrive queryForFilesInsertWithObject:driveFile
uploadParameters:uploadParameters];
[self.driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
GTLDriveFile *updatedFile,
NSError *error) {
if (error == nil) {
NSLog(@"\n\nfile uploaded into google drive\\<my_folder> foler");
} else {
NSLog(@"\n\nfile uplod failed google drive\\<my_folder> foler");
}
}];
}