0

Это мой кодОшибка для загрузки видео на сервер YouTube через Google API

загрузки видео размер 7Mb

загрузки видео типа mp4

category.SelectedItem. Текст: видео/mp4

если (FileUpload1.PostedFile! = NULL) {

 HttpPostedFile postfiles = FileUpload1.PostedFile; 
     if (postfiles.ContentLength > 0) 
     { 
      System.IO.Stream iStream = postfiles.InputStream; 
      byte[] filedata = new byte[postfiles.ContentLength]; 
      iStream.Read(filedata, 0, postfiles.ContentLength); 
      postfiles.SaveAs(@"c:\Temp\" + postfiles.FileName); 
      YouTubeRequestSettings settings = new YouTubeRequestSettings("AAA", youtube_DVkey, g_username, g_password); 
      YouTubeRequest request = new YouTubeRequest(settings); 
      Video newvideo = new Video(); 
      newvideo.Title = txtTitle.Text; 
      newvideo.Tags.Add(new MediaCategory(category.SelectedItem.Text, YouTubeNameTable.CategorySchema)); 
      newvideo.Keywords = txtKeywords.Text; 
      newvideo.Description = txtDescription.Text; 
      newvideo.Private = false; 
      newvideo.Tags.Add(new MediaCategory(txtTitle.Text.Trim(), YouTubeNameTable.DeveloperTagSchema)); 
      newvideo.YouTubeEntry.Location = new Google.GData.Extensions.Location.GeoRssWhere(37, -122); 
      newvideo.YouTubeEntry.MediaSource = new MediaFileSource(@"c:\Temp\" + postfiles.FileName, Video_type.SelectedItem.Text); 
      try 
      { 
       Video result_video = request.Upload(youtubeaccount, newvideo); 
       File.Delete(@"c:\Temp\" + postfiles.FileName); 
       Response.Redirect("gallery.aspx"); 

      } 
      catch (Google.GData.Client.GDataRequestException ex) 
      { 
       Response.Write(ex.ToString()); 
      } 
      catch (Google.GData.Client.InvalidCredentialsException ex) 
      { 
       Response.Write("Invalid credentials" + ex.ToString()); 
      } 
      catch(Exception ex) 
      { 
       Response.Write("Failed to upload!" + ex); 
      } 
     } 
    } 

Исключение

Не удалось загрузить System.Net.WebException: Запрос был прерван: Запрос был отменен , ---> System.IO.IOException: не удается закрыть поток , пока не будут записаны все байты. на System.Net.ConnectStream.CloseInternal (Boolean, Boolean InternalCall ABORTING) --- Конец внутренней трассировки стека исключений --- в System.Net.ConnectStream.CloseInternal (Boolean, Boolean InternalCall прерывающимся) в системе. Net.ConnectStream.System.Net.ICloseEx.CloseEx (CloseExState closeState) в System.Net.ConnectStream.Dispose (Boolean disposing) в System.IO.Stream.Close() в Google.GData.Client.GDataGAuthRequest.CopyRequestData() в Google.GData.Client.GDataGAuthRequest.Execute (Int32 retryCounter) при Google.GData.Client.GDataGAuthRequest.Execute() в Google.GData.Client.MediaService.EntrySend (Uri feedUri, AtomBase baseEntry, тип GDataRequestType, данные AsyncSendData) при Google.GData.Client.Service.Insert (Uri feedUri, AtomEntry newEntry, AsyncSendData данных) на Google.GData.Client.Service.Insert [TEntry] (Uri feedUri, TEntry запись) на Google.GData.YouTube.YouTubeService.Upload (String имя пользователя, YouTubeEntry вход) на Google.YouTube.YouTubeRequest.Upload (String имя пользователя, видео v) на Youtube_upload.Page_Load (отправитель объекта, EventArgs е) в d: \ Kidzaina_Final \ video_upload.aspx.cs: строка 67

ответ