我開發一個應用程序在iOS版8,我已通過安裝下面的吊艙集成谷歌驅動器:在iOS版谷歌驅動器集成到上傳PDF文件
pod platform :ios, '8.0'
pod 'GoogleAPIClient/Drive', '~> 1.0.0'
pod 'GTMOAuth2', '~> 1.1.0'
當我把代碼上傳PDF文件,我正在以下錯誤:
- 屬性「標題」不是類型「GTLDriveFile *」
- 使用未聲明的標識符「GTLDriveParentReference」的對象中找到。
- 沒有已知的選擇器'queryForFilesInsertWithObject:uploadParameters:'的類方法。
這是我的代碼:
GTLDriveFile *driveFile = [GTLDriveFile object];
driveFile.mimeType = @"application/pdf";
driveFile.originalFilename = @"database.pdf";
driveFile.name = @"database.pdf";
driveFile.size = fileSizeNumber;
NSString *parentId = @"root";
driveFile.parents = @[parentId];
NSData *fileContent = [[NSData alloc] initWithContentsOfFile:fileName];
GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithData:fileContent MIMEType:@"application/pdf"];
GTLDriveParentReference *parentRef = [GTLDriveParentReference object];
parentRef.identifier = folderIdentifier; // identifier property of the folder
driveFile.parents = @[ parentRef ];
GTLQueryDrive *query = [GTLQueryDrive queryForFilesInsertWithObject:driveFile uploadParameters:uploadParameters];
[self.service 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");
}
}];
謝謝你解決第一個錯誤。可以請你讓我知道關於其他兩個 –
2.沒有GTLDriveParentReference類,所以刪除這些行。 –
3.使用'queryForFilesCreateWithObject'而不是'queryForFilesInsertWithObject' –