我正在尝试在谷歌硬盘上传文件。 这是我的代码。
NSLog(@"authorizer : %@",self.service.authorizer);
GTLServiceDrive *driveService = self.service;
NSLog(@"auth : %@",driveService.authorizer);
NSString *title = @"myContactList.csv";
NSString *mimeType = @"csv";
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:fullFilePath error:nil];
NSNumber *fileSizeNumber = [fileAttributes objectForKey:NSFileSize];
GTLDriveFile *metadata = [GTLDriveFile object];
metadata.name = title;
metadata.mimeType = mimeType;
metadata.originalFilename = title;
metadata.size = fileSizeNumber;
// NSData *data = [content dataUsingEncoding:NSUTF8StringEncoding];
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:fullFilePath];
GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithFileHandle:file
MIMEType:mimeType];
GTLQueryDrive *query = [GTLQueryDrive queryForFilesCreateWithObject:metadata
uploadParameters:uploadParameters];
[driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
GTLDriveFile *updatedFile,
NSError *error) {
if (error == nil) {
NSLog(@"File %@", updatedFile);
} else {
NSLog(@"An error occurred: %@", error);
}
}];
但我收到错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[GTMHTTPUploadFetcher uploadFetcherWithRequest:uploadMIMEType:chunkSize:fetcherService:]:
请帮助解决此问题。我正在尝试最近4天。但没有得到任何解决方案。