我将 Google drive sdk 与我的 iOS 应用程序集成在一起。但我不知道如何将文件上传到 Google 驱动器特定文件夹。
这是用于上传文件的代码。但是这个将文件上传到我的谷歌驱动器根文件夹。任何人共享代码以将文件上传到谷歌驱动器特定文件夹?
我的代码:
-(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");
}
}];
}