原始文件总是“未知"的通过 Youtube API v3 上传时 [英] Raw File is always "unknown" when uploaded through Youtube API v3
问题描述
任何使用 .Net Youtube API v3 C# 上传的视频在检查上传文件的原始文件名(Raw 文件)时总是被视为未知".
Any video that is uploaded using .Net Youtube API v3 C# is always regarded as "unknown" when you check the original file name of the uploaded file (Raw file).
我搜索了很多,可以找到一些有相同问题但没有解决方案的,所以我不知道是否每个人都得到了它,这不是什么大事,或者人们是否知道解决方案.
I have searched a lot and can find some with same issues but no solution, so i don't know if everyone got it and it's just not a big thing or if ppl know of a solution.
上传的代码是原始示例代码(我尝试修改内容以了解有用).
The code for uploading is the original sample code (i tried modifying stuff to know avail).
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 循环来获取视频.
That code is same as the sample code except that i got a for loop for getting the videos.
我不知道这个问题是仅在 C# 上,还是我只是瞎了眼而解决方案是显而易见的.
I don't know if this problem is only on C#, or if i am just blind and the solution is obvious.
我在他们的错误跟踪器上发布了一个问题以防万一:https://code.google.com/p/gdata-issues/issues/detail?id=7140&can=6&sort=-id&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary
I have issued an issue at their bug tracker just in case: https://code.google.com/p/gdata-issues/issues/detail?id=7140&can=6&sort=-id&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary
谢谢.
推荐答案
要设置RAW文件名,添加到HTTP Hearder:
To set RAW filename, add to HTTP Hearder:
Slug:"+ 您的文件名.
"Slug: "+ your filename.
我不使用谷歌库,所以我不知道如何使用 .Net Youtube API v3 C# 进行设置
I don't use google library, so I don't know how to set this using .Net Youtube API v3 C#
这篇关于原始文件总是“未知"的通过 Youtube API v3 上传时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!