我正在尝试将视频上传到 YouTube API...如果我的视频文件小于 4 MB,它可以正常工作。
下面是我的代码..我认为这个问题与请求长度有关?!
更新:我得到的错误是“在写入所有字节之前无法关闭流。”
上传代码
YouTubeRequestSettings settings = new YouTubeRequestSettings("App NAME", "DeveloperKEY", "UserName", "Password");
YouTubeRequest request = new YouTubeRequest(settings);
request.Settings.Timeout = 9999999;
Video newVideo = new Video();
newVideo.Title = "Movie size 3 MB";
newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
newVideo.Keywords = "cars, funny";
newVideo.Description = "My description";
newVideo.YouTubeEntry.Private = false;
newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema));
string videoPath = "c:\\1.flv";
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(videoPath, GetContentType(videoPath));
Video createdVideo = request.Upload(newVideo);
litMessage.Text = "Video " + newVideo.Title + " uploaded.";
网页配置
<httpRuntime
executionTimeout="240"
maxRequestLength="40960"
requestLengthDiskThreshold="80"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="5000"
enableKernelOutputCache="true"
enableVersionHeader="true"
requireRootedSaveAsPath="true"
enable="true"
shutdownTimeout="90"
delayNotificationTimeout="5"
waitChangeNotification="0"
maxWaitChangeNotification="0"
enableHeaderChecking="true"
sendCacheControlHeader="true"
apartmentThreading="false" />