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");
}
}];
}
I don't know iOS, so may be off base, but does this code from https://developers.google.com/drive/v2/reference/files/insert help
GTLServiceTicket *_editFileListTicket;
You need to set the
parents
property of yourdriveFile
reference.