gpt4 book ai didi

asp.net - 将大文件上传到 YouTube API (.NET)

转载 作者:行者123 更新时间:2023-12-04 23:53:59 25 4
gpt4 key购买 nike

我正在尝试将视频上传到 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.";

Web.config

<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" />

最佳答案

我不认为这是请求长度。据我所知,当您收到上传的文件时,您会使用它。在我看来,某处有超时。在您的代码和 Web.Config 的 HTTPRuntime 部分中提高超时值,看看是否有效。

关于asp.net - 将大文件上传到 YouTube API (.NET),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5093769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com