YouTube에 동영상을 올리기위한 POC ASP.NET MVC 애플리케이션을 만들고 있습니다. 동영상을 업로드하려고하면 WebException
이있는 GDataRequestException
이 내부 예외로 표시됩니다.Youtube API를 통해 YouTube에 비디오를 업로드하면 WebException이 발생합니다. - (500) 내부 서버 오류
(500) Internal Server Error.
The stacktrace of the WebException is:
at System.Net.HttpWebRequest.GetResponse()
at Google.GData.Client.GDataRequest.Execute()
내 코드입니다 :
public ActionResult oauth2callback(string code)
{
if (!string.IsNullOrWhiteSpace(code))
{
JObject json;
NameValueCollection postData = new NameValueCollection();
postData.Add("code", code);
postData.Add("client_id", "The client ID");
postData.Add("client_secret", "The secret code");
postData.Add("redirect_uri", "http://localhost:64896/home/oauth2callback");
postData.Add("grant_type", "authorization_code");
json = JObject.Parse(
HttpClient.PostUrl(
new Uri("https://accounts.google.com/o/oauth2/token"), postData));
string accessToken = json["access_token"].ToString();
string refreshToken = json["refresh_token"].ToString();
bool isBearer =
string.Compare(json["token_type"].ToString(),
"Bearer",
true,
CultureInfo.CurrentCulture) == 0;
var settings = new YouTubeRequestSettings("App name",
"API key from simple API access", accessToken);
var request = new YouTubeRequest(settings);
Video newVideo = new Video();
newVideo.Title = "Test Video";
newVideo.Keywords = "key 1 , key 2";
newVideo.Tags.Add(new MediaCategory("Games", YouTubeNameTable.CategorySchema));
newVideo.Description = "Upload testing";
newVideo.YouTubeEntry.Private = false;
newVideo.Private = true;
newVideo.YouTubeEntry.MediaSource = new
MediaFileSource(@"C:\Users\Kaare\Videos\TestVideo1.avi", "video/x-msvideo");
try
{
Video createdVideo = request.Upload(newVideo);
return View();
}
catch (GDataRequestException exp)
{
//Do something mening full
}
}
else
{
return RedirectToAction("LoginFail");
}
}
너희들의 잘못가는 뭐죠의 어떤 생각을 가지고 있습니까 이것은 내가 가진 메시지입니다?
YouTube에서 동영상을 가져오고, 변경하고 삭제할 수 있습니다. 그래서 그것은 실패한 업로드 일뿐입니다. –
작고 짧은 비디오 파일을 사용해 보셨습니까? 나는 더 길거나 더 큰 파일에 종종 문제가 있었습니까? – Akku
비디오 파일의 크기는 2,63 MB입니다. 그것은 9 sek 걸립니다. 재생할 수 있습니다. 따라서 그다지 크지는 않습니다 :-) –