iOS 版 GData Youtube 上传崩溃
我正在尝试使用 GData Objective C 项目 v1.12.0 将视频上传到 youtube。我按照以下指南将 GData 与我的项目链接起来: http://mischneider.net/?p=377#comment-1277
全部似乎链接正确,但我不断收到此错误消息:
2011-06-23 15:06:30.729[79217:207] * -GDataServiceBase fetchObjectWithURL:objectClass:objectToPost:ETag:httpMethod:delegate:didFinishSelector:completionHandler:retryInitationValue:ticket: 中断言失败/Users/aalesia88/Desktop/VOKAL/Development/SSB-Youtube/GData/BaseClasses/GDataServiceBase.m:603 2011-06-23 15:06:30.731[79217:207] * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“需要 GDataHTTPUploadFetcher”
这是我在调用上传过程时使用的方法:
- (GDataServiceGoogleYouTube *)youTubeService
{
GDataServiceGoogleYouTube* service = nil;
if (!service) {
service = [[GDataServiceGoogleYouTube alloc] init];
[service setShouldCacheDatedData:YES];
[service setServiceShouldFollowNextLinks:YES];
[service setIsServiceRetryEnabled:YES];
}
SSBYoutubeCredentials *currentUser = [SSBYoutubeCredentials getCurrentUser];
NSString *username = currentUser.username;
NSString *password = currentUser.password;
if ([username length] > 0 && [password length] > 0) {
[service setUserCredentialsWithUsername:username
password:password];
} else {
// fetch unauthenticated
[service setUserCredentialsWithUsername:nil
password:nil];
}
NSString *devKey = DEVELOPER_KEY;
[service setYouTubeDeveloperKey:devKey];
return service;
}
- (void)setUploadTicket:(GDataServiceTicket *)ticket
{
if (uploadTicket != nil) {
[uploadTicket release];
}
uploadTicket = [ticket retain];
}
- (void)uploadVideoFile
{
NSString *devKey = DEVELOPER_KEY;
GDataServiceGoogleYouTube *service = [self youTubeService];
[service setYouTubeDeveloperKey:devKey];
SSBYoutubeCredentials *currentUser = [SSBYoutubeCredentials getCurrentUser];
NSString *username = currentUser.username;
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username];
// load the file data
NSString *path;
#if !TARGET_IPHONE_SIMULATOR
path = self.videoPath;
#else
path = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];;
#endif
NSData *data = [NSData dataWithContentsOfFile:path];
NSString *filename = [path lastPathComponent];
// gather all the metadata needed for the mediaGroup
NSString *titleStr = self.trick;
GDataMediaTitle *title = [GDataMediaTitle textConstructWithString:titleStr];
NSString *categoryStr = @"SSB";
GDataMediaCategory *category = [GDataMediaCategory mediaCategoryWithString:categoryStr];
[category setScheme:kGDataSchemeYouTubeCategory];
NSString *descStr = self.description;
GDataMediaDescription *desc = [GDataMediaDescription textConstructWithString:descStr];
NSString *keywordsStr = @"SuperShredBros";
GDataMediaKeywords *keywords = [GDataMediaKeywords keywordsWithString:keywordsStr];
BOOL isPrivate = NO;
GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup];
[mediaGroup setMediaTitle:title];
[mediaGroup setMediaDescription:desc];
[mediaGroup addMediaCategory:category];
[mediaGroup setMediaKeywords:keywords];
[mediaGroup setIsPrivate:isPrivate];
NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:path
defaultMIMEType:@"video/mp4"];
// create the upload entry with the mediaGroup and the file
GDataEntryYouTubeUpload *entry;
entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup
data:data
MIMEType:mimeType
slug:filename];
SEL progressSel = @selector(ticket:hasDeliveredByteCount:ofTotalByteCount:);
[service setServiceUploadProgressSelector:progressSel];
GDataServiceTicket *ticket;
ticket = [service fetchEntryByInsertingEntry:entry
forFeedURL:url
delegate:self
didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)];
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.mode = MBProgressHUDModeDeterminate;
HUD.labelText = @"Uploading...";
[self setUploadTicket:ticket];
}
如果有人对此有任何见解问题将会非常有帮助。
谢谢, 安东尼
I'm trying to use the GData objective c project v1.12.0 to upload a video to youtube. I followed the following guide to get GData linked with my project:
http://mischneider.net/?p=377#comment-1277
It all seems to be linked properly, but I keep getting this error message:
2011-06-23 15:06:30.729[79217:207] * Assertion failure in -GDataServiceBase fetchObjectWithURL:objectClass:objectToPost:ETag:httpMethod:delegate:didFinishSelector:completionHandler:retryInvocationValue:ticket:, /Users/aalesia88/Desktop/VOKAL/Developement/SSB-Youtube/GData/BaseClasses/GDataServiceBase.m:603
2011-06-23 15:06:30.731[79217:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'GDataHTTPUploadFetcher needed'
Here is my methods used in calling the upload procedure:
- (GDataServiceGoogleYouTube *)youTubeService
{
GDataServiceGoogleYouTube* service = nil;
if (!service) {
service = [[GDataServiceGoogleYouTube alloc] init];
[service setShouldCacheDatedData:YES];
[service setServiceShouldFollowNextLinks:YES];
[service setIsServiceRetryEnabled:YES];
}
SSBYoutubeCredentials *currentUser = [SSBYoutubeCredentials getCurrentUser];
NSString *username = currentUser.username;
NSString *password = currentUser.password;
if ([username length] > 0 && [password length] > 0) {
[service setUserCredentialsWithUsername:username
password:password];
} else {
// fetch unauthenticated
[service setUserCredentialsWithUsername:nil
password:nil];
}
NSString *devKey = DEVELOPER_KEY;
[service setYouTubeDeveloperKey:devKey];
return service;
}
- (void)setUploadTicket:(GDataServiceTicket *)ticket
{
if (uploadTicket != nil) {
[uploadTicket release];
}
uploadTicket = [ticket retain];
}
- (void)uploadVideoFile
{
NSString *devKey = DEVELOPER_KEY;
GDataServiceGoogleYouTube *service = [self youTubeService];
[service setYouTubeDeveloperKey:devKey];
SSBYoutubeCredentials *currentUser = [SSBYoutubeCredentials getCurrentUser];
NSString *username = currentUser.username;
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username];
// load the file data
NSString *path;
#if !TARGET_IPHONE_SIMULATOR
path = self.videoPath;
#else
path = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];;
#endif
NSData *data = [NSData dataWithContentsOfFile:path];
NSString *filename = [path lastPathComponent];
// gather all the metadata needed for the mediaGroup
NSString *titleStr = self.trick;
GDataMediaTitle *title = [GDataMediaTitle textConstructWithString:titleStr];
NSString *categoryStr = @"SSB";
GDataMediaCategory *category = [GDataMediaCategory mediaCategoryWithString:categoryStr];
[category setScheme:kGDataSchemeYouTubeCategory];
NSString *descStr = self.description;
GDataMediaDescription *desc = [GDataMediaDescription textConstructWithString:descStr];
NSString *keywordsStr = @"SuperShredBros";
GDataMediaKeywords *keywords = [GDataMediaKeywords keywordsWithString:keywordsStr];
BOOL isPrivate = NO;
GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup];
[mediaGroup setMediaTitle:title];
[mediaGroup setMediaDescription:desc];
[mediaGroup addMediaCategory:category];
[mediaGroup setMediaKeywords:keywords];
[mediaGroup setIsPrivate:isPrivate];
NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:path
defaultMIMEType:@"video/mp4"];
// create the upload entry with the mediaGroup and the file
GDataEntryYouTubeUpload *entry;
entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup
data:data
MIMEType:mimeType
slug:filename];
SEL progressSel = @selector(ticket:hasDeliveredByteCount:ofTotalByteCount:);
[service setServiceUploadProgressSelector:progressSel];
GDataServiceTicket *ticket;
ticket = [service fetchEntryByInsertingEntry:entry
forFeedURL:url
delegate:self
didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)];
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.mode = MBProgressHUDModeDeterminate;
HUD.labelText = @"Uploading...";
[self setUploadTicket:ticket];
}
If anyone has any insight into this problem that would be very helpful.
Thanks,
Anthony
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该消息来自 GDataServiceBase.m。它表明 GTMHTTPUploadFetcher 类未链接到您的应用程序。
由于类文件未在调试或发布构建目标中链接,或者由于未设置预处理器定义 GDATA_INCLUDE_YOUTUBE_SERVICE,该类可能会丢失,如 http://code.google.com/p/gdata-objectivec-client/wiki/BuildingTheLibrary
The message is from GDataServiceBase.m. It indicates that the class GTMHTTPUploadFetcher is not linked in to your application.
The class may be missing due to the class file not being linked in the debug or release build target, or due to the preprocessor define GDATA_INCLUDE_YOUTUBE_SERVICE not being set, as described under "Removing Unneeded Code" at http://code.google.com/p/gdata-objectivec-client/wiki/BuildingTheLibrary
是的,这似乎是一个链接问题。我按照该链接上的说明直接编译到我的代码中,并删除了我不需要的类,例如 googledocs。一旦我这样做了,一切都构建良好,我就可以上传了。
感谢您的帮助。
Yeah, it seemed to be a linking issue. I followed the instructions on that link to compile directly into my code and removed the classes I didn't need such as googledocs. Once I did that, everything built fine and I was able to upload.
Thanks for the help.