久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='zFZOL'><style id='zFZOL'><dir id='zFZOL'><q id='zFZOL'></q></dir></style></legend>

<small id='zFZOL'></small><noframes id='zFZOL'>

    <tfoot id='zFZOL'></tfoot>

        <i id='zFZOL'><tr id='zFZOL'><dt id='zFZOL'><q id='zFZOL'><span id='zFZOL'><b id='zFZOL'><form id='zFZOL'><ins id='zFZOL'></ins><ul id='zFZOL'></ul><sub id='zFZOL'></sub></form><legend id='zFZOL'></legend><bdo id='zFZOL'><pre id='zFZOL'><center id='zFZOL'></center></pre></bdo></b><th id='zFZOL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='zFZOL'><tfoot id='zFZOL'></tfoot><dl id='zFZOL'><fieldset id='zFZOL'></fieldset></dl></div>
        • <bdo id='zFZOL'></bdo><ul id='zFZOL'></ul>
      1. YouTube C# API V3,如何恢復(fù)中斷的上傳?

        YouTube C# API V3, how do you resume an interrupted upload?(YouTube C# API V3,如何恢復(fù)中斷的上傳?)
        <tfoot id='1WS0I'></tfoot>
        <i id='1WS0I'><tr id='1WS0I'><dt id='1WS0I'><q id='1WS0I'><span id='1WS0I'><b id='1WS0I'><form id='1WS0I'><ins id='1WS0I'></ins><ul id='1WS0I'></ul><sub id='1WS0I'></sub></form><legend id='1WS0I'></legend><bdo id='1WS0I'><pre id='1WS0I'><center id='1WS0I'></center></pre></bdo></b><th id='1WS0I'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1WS0I'><tfoot id='1WS0I'></tfoot><dl id='1WS0I'><fieldset id='1WS0I'></fieldset></dl></div>
        • <bdo id='1WS0I'></bdo><ul id='1WS0I'></ul>
          <legend id='1WS0I'><style id='1WS0I'><dir id='1WS0I'><q id='1WS0I'></q></dir></style></legend>

            1. <small id='1WS0I'></small><noframes id='1WS0I'>

                <tbody id='1WS0I'></tbody>
                • 本文介紹了YouTube C# API V3,如何恢復(fù)中斷的上傳?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  我不知道如何在 C# YouTube API V3 中恢復(fù)中斷的上傳.

                  I can't work out how to resume an interrupted upload in V3 of the C# YouTube API.

                  我現(xiàn)有的代碼使用 V1 并且工作正常,但我正在切換到 V3.

                  My existing code uses V1 and works fine but I'm switching to V3.

                  如果我在不更改任何內(nèi)容的情況下調(diào)用 UploadAsync(),它會(huì)從頭開(kāi)始.使用 Fiddler,我可以看到未遵循 此處給出的協(xié)議,并且上傳重新開(kāi)始.

                  If I call UploadAsync() without changing anything, it starts from the beginning. Using Fiddler, I can see the protocol given here is not followed and the upload restarts.

                  我嘗試按照 V1 設(shè)置流中的位置,但沒(méi)有可用的 ResumeAsync() 方法.

                  I've tried setting the position within the stream as per V1 but there is no ResumeAsync() method available.

                  Python 示例使用 NextChunk,但 SendNextChunk 方法受到保護(hù),在 C# 中不可用.

                  The Python example uses NextChunk but the SendNextChunk method is protected and not available in C#.

                  在下面的代碼中,如果我讓 UploadVideo() 和 Resume() 完成,但上傳的是整個(gè)視頻而不是其余部分,則它們都可以正常工作.

                  In the code below, both UploadVideo() and Resume() work fine if I leave them to completion but the entire video is uploaded instead of just the remaining parts.

                  如何使用 google.apis.youtube.v3 恢復(fù)中斷的上傳?

                  How do I resume an interrupted upload using google.apis.youtube.v3?

                  這是我目前嘗試過(guò)的 C# 代碼.

                  Here is the C# code I have tried so far.

                  private ResumableUpload<Video> UploadVideo(
                      YouTubeService youTubeService, Video video, Stream stream, UserCredential userCredentials)
                  {
                      var resumableUpload = youTubeService.Videos.Insert(video, 
                          "snippet,status,contentDetails", stream, "video/*");
                      resumableUpload.OauthToken = userCredentials.Token.AccessToken;
                      resumableUpload.ChunkSize = 256 * 1024;
                      resumableUpload.ProgressChanged += resumableUpload_ProgressChanged;
                      resumableUpload.ResponseReceived += resumableUpload_ResponseReceived;                   
                      resumableUpload.UploadAsync();
                      return resumableUpload;
                  }
                  
                  private void Resume(ResumableUpload<Video> resumableUpload)
                  {   
                      //I tried seeking like V1 but it doesn't work
                      //if (resumableUpload.ContentStream.CanSeek)
                      //  resumableUpload.ContentStream.Seek(resumableUpload.ContentStream.Position, SeekOrigin.Begin);
                  
                      resumableUpload.UploadAsync(); // <----This restarts the upload                             
                  }
                  
                  void resumableUpload_ResponseReceived(Video obj)
                  {                   
                      Debug.WriteLine("Video status: {0}", obj.Status.UploadStatus);                      
                  }
                  
                  void resumableUpload_ProgressChanged(IUploadProgress obj)
                  {
                      Debug.WriteLine("Position: {0}", (resumableUploadTest == null) ? 0 : resumableUploadTest.ContentStream.Position);   
                      Debug.WriteLine("Status: {0}", obj.Status);
                      Debug.WriteLine("Bytes sent: {0}", obj.BytesSent);
                  }
                  
                  private void button2_Click(object sender, EventArgs e)
                  {
                      Resume(resumableUploadTest);
                  }
                  

                  任何解決方案/建議/演示或google.apis.youtube.v3"源代碼的鏈接都會(huì)非常有幫助.

                  Any solution/suggestion/demo or a link to the "google.apis.youtube.v3" source code will be very helpful.

                  提前致謝!

                  新信息

                  我仍在努力,我相信 API 還沒(méi)有完成.要么那個(gè),要么我錯(cuò)過(guò)了一些簡(jiǎn)單的東西.

                  I'm still working on this and I believe the API simply isn't finished. Either that or I'm missing something simple.

                  我仍然找不到google.apis.youtube.v3"源代碼,所以我下載了最新的google-api-dotnet-client"源代碼.這包含 YouTube API 使用的 ResumableUpload 類.

                  I still can't find the "google.apis.youtube.v3" source code so I downloaded the latest "google-api-dotnet-client" source code. This contains the ResumableUpload class used by the YouTube API.

                  通過(guò)跳過(guò) UploadAsync() 方法中的前四行代碼,我成功地繼續(xù)上傳.我創(chuàng)建了一個(gè)名為 ResumeAsync() 的新方法,它是 UploadAsync() 的副本,其中刪除了前四行初始化代碼.一切正常,上傳從原來(lái)的位置恢復(fù)并完成.

                  I managed to successfully continue an upload by skipping the first four lines of code in the UploadAsync() method. I created a new method called ResumeAsync(), a copy of UploadAsync() with the first four lines of initialization code removed. Everything worked and the upload resumed from where it was and completed.

                  我不想更改 API 中的代碼,所以如果有人知道我應(yīng)該如何使用它,請(qǐng)告訴我.

                  I'd rather not be changing code in the API so if anyone knows how I should be using this, let me know.

                  我會(huì)繼續(xù)努力,看看能不能解決.

                  I'll keep plugging away and see if I can work it out.

                  這是原始的 UploadAsync() 方法和我的 ResumeAsync() hack.

                  This is the original UploadAsync() method and my ResumeAsync() hack.

                  public async Task<IUploadProgress> UploadAsync(CancellationToken cancellationToken)
                  {
                      try
                      {
                          BytesServerReceived = 0;
                          UpdateProgress(new ResumableUploadProgress(UploadStatus.Starting, 0));
                          // Check if the stream length is known.
                          StreamLength = ContentStream.CanSeek ? ContentStream.Length : UnknownSize;
                          UploadUri = await InitializeUpload(cancellationToken).ConfigureAwait(false);
                  
                          Logger.Debug("MediaUpload[{0}] - Start uploading...", UploadUri);
                  
                          using (var callback = new ServerErrorCallback(this))
                          {
                              while (!await SendNextChunkAsync(ContentStream, cancellationToken).ConfigureAwait(false))
                              {
                                  UpdateProgress(new ResumableUploadProgress(UploadStatus.Uploading, BytesServerReceived));
                              }
                              UpdateProgress(new ResumableUploadProgress(UploadStatus.Completed, BytesServerReceived));
                          }
                      }
                      catch (TaskCanceledException ex)
                      {
                          Logger.Error(ex, "MediaUpload[{0}] - Task was canceled", UploadUri);
                          UpdateProgress(new ResumableUploadProgress(ex, BytesServerReceived));
                          throw ex;
                      }
                      catch (Exception ex)
                      {
                          Logger.Error(ex, "MediaUpload[{0}] - Exception occurred while uploading media", UploadUri);
                          UpdateProgress(new ResumableUploadProgress(ex, BytesServerReceived));
                      }
                  
                      return Progress;
                  }
                  
                  public async Task<IUploadProgress> ResumeAsync(CancellationToken cancellationToken)
                  {
                      try
                      {
                          using (var callback = new ServerErrorCallback(this))
                          {
                              while (!await SendNextChunkAsync(ContentStream, cancellationToken).ConfigureAwait(false))
                              {
                                  UpdateProgress(new ResumableUploadProgress(UploadStatus.Uploading, BytesServerReceived));
                              }
                              UpdateProgress(new ResumableUploadProgress(UploadStatus.Completed, BytesServerReceived));
                          }
                      }
                      catch (TaskCanceledException ex)
                      {                       
                          UpdateProgress(new ResumableUploadProgress(ex, BytesServerReceived));
                          throw ex;
                      }
                      catch (Exception ex)
                      {                       
                          UpdateProgress(new ResumableUploadProgress(ex, BytesServerReceived));
                      }
                  
                      return Progress;
                  }
                  

                  這些是顯示上傳恢復(fù)的Fiddler 記錄.

                  These are the Fiddler records showing the upload resuming.

                  推薦答案

                  我已經(jīng)設(shè)法使用反射使其工作,并完全避免了修改 API 的需要.為了完整起見(jiàn),我將記錄該過(guò)程,但不建議這樣做.在可恢復(fù)的上傳對(duì)象中設(shè)置私有屬性不是一個(gè)好主意.

                  I've managed to get this to work using reflection and avoided the need to modify the API at all. For completeness, I'll document the process but it isn't recommended. Setting private properties in the resumable upload object is not a great idea.

                  當(dāng)您的可恢復(fù)上傳對(duì)象在應(yīng)用程序重啟或重啟后被銷(xiāo)毀時(shí),您仍然可以使用 Google.Apis.YouTube.v3 客戶端庫(kù).

                  When your resumeable upload object has been destroyed after an application restart or reboot, you can still resume an upload using version "1.8.0.960-rc" of the Google.Apis.YouTube.v3 Client Library.

                  private static void SetPrivateProperty<T>(Object obj, string propertyName, object value)
                  {
                      var propertyInfo = typeof(T).GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance);
                      if (propertyInfo == null) return;
                      propertyInfo.SetValue(obj, value, null);
                  }
                  
                  private static object GetPrivateProperty<T>(Object obj, string propertyName)
                  {
                      if (obj == null) return null;
                      var propertyInfo = typeof(T).GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance);
                      return propertyInfo == null ? null : propertyInfo.GetValue(obj, null);
                  }
                  

                  您需要在 ProgressChanged 事件期間保存 UploadUri.

                  You need to save the UploadUri during the ProgressChanged event.

                  Upload.ResumeUri = GetPrivateProperty<ResumableUpload<Video>>(InsertMediaUpload, "UploadUri") as Uri;
                  

                  您需要在調(diào)用 ResumeAsync 之前設(shè)置 UploadUri 和 StreamLength.

                  You need to set the UploadUri and StreamLength before calling ResumeAsync.

                  private const long UnknownSize = -1;
                  SetPrivateProperty<ResumableUpload<Video>>(InsertMediaUpload, "UploadUri", Upload.ResumeUri);
                  SetPrivateProperty<ResumableUpload<Video>>(InsertMediaUpload, "StreamLength", fileStream.CanSeek ? fileStream.Length : Constants.UnknownSize);
                  Task = InsertMediaUpload.ResumeAsync(CancellationTokenSource.Token);
                  

                  這篇關(guān)于YouTube C# API V3,如何恢復(fù)中斷的上傳?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  What are good algorithms for vehicle license plate detection?(車(chē)牌檢測(cè)有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運(yùn)行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時(shí)刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時(shí)突出顯示行)
                  Calling A Button OnClick from a function(從函數(shù)調(diào)用按鈕 OnClick)

                  <small id='h0wYY'></small><noframes id='h0wYY'>

                    <tfoot id='h0wYY'></tfoot>

                    1. <legend id='h0wYY'><style id='h0wYY'><dir id='h0wYY'><q id='h0wYY'></q></dir></style></legend>
                        <bdo id='h0wYY'></bdo><ul id='h0wYY'></ul>

                          <tbody id='h0wYY'></tbody>

                          <i id='h0wYY'><tr id='h0wYY'><dt id='h0wYY'><q id='h0wYY'><span id='h0wYY'><b id='h0wYY'><form id='h0wYY'><ins id='h0wYY'></ins><ul id='h0wYY'></ul><sub id='h0wYY'></sub></form><legend id='h0wYY'></legend><bdo id='h0wYY'><pre id='h0wYY'><center id='h0wYY'></center></pre></bdo></b><th id='h0wYY'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='h0wYY'><tfoot id='h0wYY'></tfoot><dl id='h0wYY'><fieldset id='h0wYY'></fieldset></dl></div>
                            主站蜘蛛池模板: 中文字幕精品一区二区三区在线 | 久久夜色精品国产 | 三级av在线 | 精品国产欧美 | 亚洲欧美日韩中文在线 | 免费看a | 日本黄色的视频 | va精品 | 国产精品久久久久久久一区探花 | 精品国产视频 | 中文字幕精 | 一级毛片观看 | aaaaaa大片免费看最大的 | 日韩有码一区 | 日韩综合一区 | 色香蕉在线 | 一区二区三区不卡视频 | 精品久久久久一区二区国产 | 国产成人99久久亚洲综合精品 | 九九热在线免费视频 | 久久久久久九九九九九九 | 在线观看中文字幕 | 涩涩视频在线看 | 亚洲黄色高清视频 | 超碰97免费在线 | 一区二区三区不卡视频 | 欧美一区二区三区在线 | h视频在线观看免费 | 国产精品夜色一区二区三区 | 97国产精品| 欧美成人黄色小说 | 一区二区三区视频 | 中文字幕一级 | 99在线免费观看 | 日韩久久成人 | 一级片免费观看 | 精品免费视频 | av先锋资源 | 91精品久久| 日韩成人在线观看 | 97国产精品视频人人做人人爱 |