我在ASP.NET C#网络应用程序中使用了YouTube API,并使用以下示例将视频上传到我的个人YouTube帐户:
https://developers.google.com/youtube/v3/code_samples/dotnet#upload_a_video
我正在上传 10 minute mp4 file ,大小为 30MB .
如果我没有对配置文件进行任何更改,API会报告“ A task was cancelled ”并在几分钟后停止上传 .
谷歌搜索后发现我不得不减少块大小并增加超时和mak上传大小 .
所以我然后将块大小更改为以下内容:
videosInsertRequest.ChunkSize = 256 * 1024;
并将followig添加到我的Web.config文件中:
<system.webServer>
<security >
<requestFiltering>
<requestLimits maxAllowedContentLength="1024000000" />
</requestFiltering>
</security >
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="104857600" executionTimeout="36000" />
</system.web>
然后,这允许我上传完整的文件,而不会失败:)
但是在调试我的Web应用程序时(从我的PC上的Visual Studio),需要上传 18 minutes . 如果我通过YouTubes自己的网站上传相同的文件 only takes 4 minutes .
What changes can I make to my config settings to make my upload time comparable with the YouTube upload??
Edit: 我注意到如果我没有将chunksize设置为任何值,它的上传速度为apbx 1Mb / s,应该足够快但在2-3分钟后失败 .
如何将超时设置为上述代码示例的最大值?