使用 .net 库通过 youtube api 在 youtube 上上传更大尺寸的视频出现错误请求已中止:请求已取消 [英] Uploading video of larger size on youtube through youtube api using .net library gives error The request was aborted: The request was canceled

查看:25
本文介绍了使用 .net 库通过 youtube api 在 youtube 上上传更大尺寸的视频出现错误请求已中止:请求已取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 youtube 上上传大小超过 4 mb 的视频时出现以下错误.

while uploading video on youtube more than 4 mb size gives following error.

The request was aborted: The request was canceled.| at
System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean
aborting) at
System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState
closeState) at System.Net.ConnectStream.Dispose(Boolean disposing) at
System.IO.Stream.Close() at
Google.GData.Client.GDataGAuthRequest.CopyRequestData() at
Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter) at
Google.GData.Client.GDataGAuthRequest.Execute() at
Google.GData.Client.MediaService.EntrySend(Uri feedUri, AtomBase
baseEntry, GDataRequestType type, AsyncSendData data) at
Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry,
AsyncSendData data) at Google.GData.Client.Service.Insert[TEntry](Uri
feedUri, TEntry entry) at
Google.GData.YouTube.YouTubeService.Upload(String userName,
YouTubeEntry entry) at Google.YouTube.YouTubeRequest.Upload(String
userName, Video v) at Google.YouTube.YouTubeRequest.Upload(Video v) at
upload.Button1_Click(Object sender, EventArgs e)

已经尝试了一些解决方案,例如

Already tried some solutions like

request.Settings.Timeout = 60 * 60 * 1000;

<httpRuntime executionTimeout="6000" maxRequestLength="100000" />

但同样的问题发生.请帮我代码如下:-

but same issue occur. Please help me Code is as Follws:-

YouTubeRequest request = new YouTubeRequest(settings);
        //request.Settings.Maximum = 9999999;
        request.Settings.Timeout = 60 * 60 * 1000;          
        Video newVideo = new Video();

        newVideo.Title = TextBox1.Text;
        newVideo.Tags.Add(new MediaCategory("People", YouTubeNameTable.CategorySchema));
        newVideo.Keywords = "cars, funny";
        newVideo.Description = TextBox2.Text;
        newVideo.YouTubeEntry.Private = false;
        newVideo.YouTubeEntry.AccessControls.Add(new YtAccessControl("list", "denied"));
        newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema));



        newVideo.YouTubeEntry.MediaSource = new MediaFileSource(f.ToString(), "video/x-flv");


        Video createdVideo = request.Upload(newVideo);

推荐答案

只需在代码中添加这 3 行并尝试,

Just add these 3 lines in your code and try,

 YouTubeService service = new YouTubeService("Test", DEVELOPERKEY);
        ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 9999999; 
        ((GDataRequestFactory)service.RequestFactory).KeepAlive = false;

如果您的问题已解决,请将其标记为答案.

Mark this as answer if your problem solved.

这篇关于使用 .net 库通过 youtube api 在 youtube 上上传更大尺寸的视频出现错误请求已中止:请求已取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆