通过Youtube API v3上传时,原始文件始终为“未知”

当您检查上载文件的原始文件名(原始文件)时,使用.Net Youtube API v3 C#上传的任何video始终被视为“未知”。

我已经搜索了很多,可以找到一些相同的问题,但没有解决方案,所以我不知道是否每个人都得到它,这不是一件大事,或者如果人们知道解决方案。

上传代码是原始示例代码(我尝试修改内容以了解有用)。

async void Upload() { _lastBytes = 0; _currentItem = -1; for (_currentItem = 0; _currentItem < WorkList.Count; _currentItem++) { var videoSource = WorkList[_currentItem]; UserCredential credential; using (var stream = new FileStream("YourJsonFile", FileMode.Open, FileAccess.Read)) { credential = await GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, // This OAuth 2.0 access scope allows an application to upload files to the // authenticated user's YouTube channel, but doesn't allow other types of access. new[] { YouTubeService.Scope.YoutubeUpload }, "user", CancellationToken.None ); } var youtubeService = new YouTubeService(new BaseClientService.Initializer { HttpClientInitializer = credential, ApplicationName = Assembly.GetExecutingAssembly().GetName().Name }); var video = new Video(); video.Snippet = new VideoSnippet(); video.Snippet.Title = videoSource.Title; if (videoSource.Description != null) video.Snippet.Description = videoSource.Description; if (videoSource.Tags != null) video.Snippet.Tags = videoSource.Tags.Split(','); video.Snippet.CategoryId = "22"; // See https://developers.google.com/youtube/v3/docs/videoCategories/list video.Status = new VideoStatus(); video.Status.PrivacyStatus = "private"; // or "private" or "public" var filePath = videoSource.Path; // Replace with path to actual movie file. using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { _size = fileStream.Length; var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status,contentDetails", fileStream, "video/*"); videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged; videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived; await videosInsertRequest.UploadAsync(); } } } 

该代码与示例代码相同,只是我有一个for循环来获取video。

我不知道这个问题是仅在C#上,还是我只是盲目而且解决方案很明显。

我已经在他们的错误跟踪器上发布了一个问题,以防万一: https : //code.google.com/p/gdata-issues/issues/detail?id = 7140&can = 6&sort = -id&cospecpec = API%20ID%20Type% 20Status% 20Priority%20Stars%20Summary

谢谢。

要设置RAW文件名,请添加到HTTP Hearder:

“S ::”+你的文件名。

我不使用谷歌库,所以我不知道如何使用.Net Youtube API v3 C#设置它