wir müssen Video auf youtube hochladen. Ich habe meine asp.net Web API verwendet, um Videos hochzuladen. also bitte, jeder kann mir helfen. Ich habe Youtube API und OAuth verwendet, kann aber jetzt nicht arbeiten. Also bitte hilf mir.Hochladen von Video auf Youtube mit asp.net Web API
0
A
Antwort
1
Ich konnte Ihnen nicht alle Prozesse in wenigen Worten erzählen. Youtube hat ein sehr gutes Beispiel in docs Look here. .Net video upload
Sie können Video-Datei in Controler über retreive:
[HttpPost]
public IHttpActionResult PostVideo(HttpPostedFileBase file){
//here convert to streame described in docs, and send request to youtube.
}
0
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Upload;
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
namespace YouTube
{
internal class UploadVideo
{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("YouTube Data API: Upload Video");
Console.WriteLine("==============================");
try
{
new UploadVideo().Run().Wait();
}
catch (AggregateException ex)
{
foreach (var e in ex.InnerExceptions)
{
Console.WriteLine("Error: " + e.Message);
}
}
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
private async Task Run()
{
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", 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 = "Youtube Uploader" // Assembly.GetExecutingAssembly().GetName().Name
});
var video = new Video();
video.Snippet = new VideoSnippet();
video.Snippet.Title = "Default Video Title";
video.Snippet.Description = "Default Video Description";
video.Snippet.Tags = new string[] { "tag1", "tag2" };
video.Snippet.CategoryId = "UCycmrK4RRMNY6CTn58r6gNA"; // See https://developers.google.com/youtube/v3/docs/videoCategories/list
video.Status = new VideoStatus();
video.Status.PrivacyStatus = "public"; // or "private" or "public"
var filePath = @"D:\1.mp4"; // Replace with path to actual movie file.
using (var fileStream = new FileStream(filePath, FileMode.Open))
{
var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*");
videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;
await videosInsertRequest.UploadAsync();
}
}
void videosInsertRequest_ProgressChanged(Google.Apis.Upload.IUploadProgress progress)
{
switch (progress.Status)
{
case UploadStatus.Uploading:
Console.WriteLine("{0} bytes sent.", progress.BytesSent);
break;
case UploadStatus.Failed:
Console.WriteLine("An error prevented the upload from completing.\n{0}", progress.Exception);
break;
}
}
void videosInsertRequest_ResponseReceived(Video video)
{
Console.WriteLine("Video id '{0}' was successfully uploaded.", video.Id);
}
}
}
Verwandte Themen
- 1. Video mit Youtube API V3 und PHP auf Youtube hochladen
- 2. Youtube API: Ein entferntes Video hochladen
- 3. Hochladen von Video auf Youtube mit Android-App mit Java
- 4. Youtube API Javascript Video auf vordefinierten Kanal hochladen
- 5. Check Duplicate Youtube API Hochladen
- 6. Hochladen von Videos auf youtube von iOS app - Youtube API
- 7. Video auf einen bestimmten Kanal von Youtube in Android hochladen
- 8. Suche Video mit YouTube API auf Android
- 9. Hochladen von Video auf YouTube (über API), aber nur auf meiner Website sichtbar
- 10. Fehler beim Hochladen mit youtube API?
- 11. Youtube API-Kontingent überschritten mit 1 Video
- 12. YouTube mit Web Audio API Audio extrahieren
- 13. Video auf youtube hochladen mit MIT App Inventor 2
- 14. YouTube API 3 Video hochladen - Zugriff nicht konfiguriert - Android
- 15. Private Video mit YouTube API - Drupal
- 16. Ios youtube api Video hochladen, Fehler userInfo protokollieren?
- 17. Kann ich ein Youtube-Video mit der Youtube-API hochladen, ohne ein GUI?
- 18. YouTube-API: Video-Datenschutzoption
- 19. Video auf youtube mit mvc-Anwendung hochladen (alles Code hinten)
- 20. Asp.net Core rc2 Web API-Datei hochladen
- 21. Youtube api Video hochladen und bezahlte Produktplatzierung einstellen
- 22. Hochladen von Video auf Youtube mit seiner REST API ohne das iOS SDK
- 23. ein Video in meinem YouTube-Kanal hochladen PHP api
- 24. Javascript hochladen Video auf Youtube mit Drag & Drop
- 25. YouTube Iframe API - Play Video auf Handy
- 26. Youtube Video api Video zeigt sich nicht
- 27. android youtube Video mit statischem Benutzernamen und Passwort hochladen
- 28. YouTube-API zum Hochladen auf den Unternehmenskanal
- 29. Get youtube DATEIURL von Video-ID-API
- 30. YouTube API v3, C# MVC - Video mit OAuth auf MY-Kanal hochladen
können Sie Ihren Code schreiben, damit wir helfen können? –
Sie können das Uploads-Protokoll für Google Api https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol verwenden, um Ihre Videos hochzuladen. Dadurch können Sie den Rest-Service anrufen, um Ihr Video hochzuladen. Sie können es mit HttpClient aufrufen . –