0

我正在尝试使用 C# API 将 500 MB 的视频上传到 YouTube。在最后一行,我收到一个参数空异常。作为第二个参数的 URI 应该是什么?这是我的代码:

[WebMethod]
public string InsertVideoToYouTube(FileStream fs, string filename, string title, string description, string userName, string password)
{
    Video newVideo = new Video();
    newVideo.Title = title;
    newVideo.Tags.Add(new MediaCategory("Sports", YouTubeNameTable.CategorySchema));
    newVideo.Description = description;
    newVideo.YouTubeEntry.Private = false;
    newVideo.YouTubeEntry.MediaSource = new MediaFileSource(fs, Path.GetFileName(filename), "video/x-ms-wmv");

    var youTubeAuthenticator = new ClientLoginAuthenticator("KenticoVideo",
                    ServiceNames.YouTube, new GDataCredentials(userName, password));
youTubeAuthenticator.DeveloperKey = "xxx";
    ResumableUploader uploader = new ResumableUploader(256);

    uploader.Insert(youTubeAuthenticator, new Uri("http://www.mysite.com"), fs, "video/x-ms-wmv", ""); // start upload
}

这是堆栈跟踪:

System.ArgumentNullException: Value cannot be null.
Parameter name: uriString
   at System.Uri..ctor(String uriString)
   at Google.GData.Client.ResumableUpload.ResumableUploader.InitiateUpload(Uri resumableUploadUri, Authenticator authentication, String contentType, String slug, Int64 contentLength, String httpMethod)
   at Google.GData.Client.ResumableUpload.ResumableUploader.InitiateUpload(Uri resumableUploadUri, Authenticator authentication, String contentType, String slug, Int64 contentLength)
   at Google.GData.Client.ResumableUpload.ResumableUploader.Insert(Authenticator authentication, Uri resumableUploadUri, Stream payload, String contentType, String slug, AsyncData data)
   at Google.GData.Client.ResumableUpload.ResumableUploader.Insert(Authenticator authentication, Uri resumableUploadUri, Stream payload, String contentType, String slug)
   at PreveaYTProxy.InsertVideoToYouTube(FileStream fs, String filename, String title, String description, String userName, String password) in c:\inetpub\wwwroot\Customers\imaginasium\PreveaYTProxy\App_Code\PreveaYTProxy.cs:line 57
   at _Default.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Customers\imaginasium\PreveaYTProxy\Default.aspx.cs:line 20
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

我使用正确的代码吗?我看了这里,但找不到我需要的代码:

https://groups.google.com/forum/#!topic/gdata-dotnet-client-library/AWoPGB9_NzE

4

0 回答 0