1
votes

I am using the youtube api to direct upload videos like this:

    YouTubeRequestSettings setting = new YouTubeRequestSettings("devpa", key, "user", "pass");
    YouTubeRequest req = new YouTubeRequest(setting);

    Video ytv = new Video();
    ytv.Title = "test video1";
    ytv.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
    ytv.Keywords = "test, dev";
    ytv.Description = "this is a test video";
    ytv.YouTubeEntry.Private = true;
    ytv.YouTubeEntry.MediaSource = new MediaFileSource(Server.MapPath("PATH"), "video/mp4");

    Video createdVideo = req.Upload(ytv);

But every time i get this error:

Cannot close stream until all bytes are written

Even though *i am uploading small videos with different extinctions (flv,mp4 ..etc) *, what is the problem?

Thanks

2
You need to set timeout. Like ytv.TimeOut = 100000000; - Emaad Ali
@EmaadAli - Had to set it on the setting itself not the video, please add the comment to answer so i can accept, thanks - Wahtever

2 Answers

1
votes

You need to set timeout. Like ytv.TimeOut = 100000000;

0
votes

Actually set the instance of

YouTubeRequestSettings.Timeout = [A LARGER NUMBER]

That's the setting you'll want to use.