Objective-CのGoogle APIクライアントライブラリ を使用してYouTubeでビデオをアップロードしようとしていますが、私はこのエラーを受け取り続けています。 YouTubeのサンプルプロジェクトで私のアカウントをもう一度実行すると、同じエラーが表示されます。アサーションエラー - [GTMHTTPUploadFetcher connectionDidFinishLoading:]
問題がどこにありますか。 YouTube Data API v3がサービスページに表示されていることを確認します。
*** Assertion failure in -[GTMHTTPUploadFetcher connectionDidFinishLoading:], /Volumes/data/Work/test/DLNew/DL/google-api-objectivec-client-read-only/Source/HTTPFetcher/GTMHTTPUploadFetcher.m:399
2013-08-30 14:28:31.399 [1250:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unexpected response data (uploading to the wrong URL?)'
私はそれがこのリンク
`#if DEBUG
// The initial response of the resumable upload protocol should have an
// empty body
//
// This assert typically happens because the upload create/edit link URL was
// not supplied with the request, and the server is thus expecting a non-
// resumable request/response.
NSAssert([[self downloadedData] length] == 0,
@"unexpected response data (uploading to the wrong URL?)");
#endif
でアプリをクラッシュさGTMHTTPUploadFetcherクラスのコードを確認してください。
NSString *path = [[NSUserDefaults standardUserDefaults] objectForKey:@"MOVIEPATH"];
NSString *filename = [path lastPathComponent];
NSString *mimeType = [self MIMETypeForFilename:filename defaultMIMEType:@"video/mp4"];
NSError *eel=nil;
NSFileHandle *handle = [NSFileHandle fileHandleForReadingFromURL:[NSURL URLWithString:path] error:&eel];
NSLog(@"error is %@",eel);
if (!handle)
{
NSLog(@"Failed to open file for reading");
return;
}
GTLServiceYouTube *service = [[GTLServiceYouTube alloc] init];
service.authorizer = self.gTMOAuth2Authentication;
GTLUploadParameters *params = [GTLUploadParameters uploadParametersWithFileHandle:handle MIMEType:mimeType];
GTLYouTubeVideoSnippet *snippet = [GTLYouTubeVideoSnippet object];
snippet.title = @"Test title";
snippet.descriptionProperty = @"Test description";
snippet.tags = [NSArray arrayWithObjects:@"TestOne", @"TestTwo" ,nil];
snippet.categoryId = @"17";
GTLYouTubeVideoStatus *status = [GTLYouTubeVideoStatus object];
status.privacyStatus = @"private";
GTLYouTubeVideo *video2 = [GTLYouTubeVideo object];
video2.snippet = snippet;
video2.status = status;
GTLQueryYouTube *query = [GTLQueryYouTube queryForVideosInsertWithObject:video2 part:@"snippet,status" uploadParameters:params];
// Perform the upload
GTLServiceTicket *ticket = [service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error)
{
if (error)
{
NSLog(@"ERROR: %@", error);
return;
}
NSLog(@"SUCCESS! %@; %@;", ticket, object);
}];
ticket.uploadProgressBlock = ^(GTLServiceTicket *ticket, unsigned long long numberOfBytesRead, unsigned long long dataLength)
{
NSLog(@"%lld/%lld", numberOfBytesRead, dataLength);
};
----------
問題私はので、私はユーチューブサイトにログインし、前にチャネルを作成する必要がありますする必要が新しいGmailアカウントからログインしました私はYouTubeにビデオをアップロードすることができます。これで、YouTubeチャンネルを作成した後で動画をアップロードできます。しかし、どのように私は他のユーザー、任意のアイデアのためにこのシナリオを扱うことができます
重要なコードを追加 –
アップロードするためのコード –
params.uploadLocationURL = nil; – blueberryfields