YouTube C# API V3, how do you resume an interrupted upload?

后端 未结 3 1938
感情败类
感情败类 2021-01-14 11:03

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

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

If I cal

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-14 11:58

    This issue has been resolved in version "1.8.0.960-rc" of the Google.Apis.YouTube.v3 Client Library.

    They've added a new method called ResumeAsync and it works fine. I wish I'd known they were working on it.

    One minor issue I needed to resolve was resuming an upload after restarting the application or rebooting. The current api does not allow for this but two minor changes resolved the issue.

    I added a new signature for the ResumeAsync method, which accepts and sets the original UploadUri. The StreamLength property needs to be initialised to avoid an overflow error.

    public Task ResumeAsync(Uri uploadUri, CancellationToken cancellationToken)
    {
        UploadUri = uploadUri;
        StreamLength = ContentStream.CanSeek ? ContentStream.Length : UnknownSize;
        return ResumeAsync(cancellationToken);
    }
    

    I also exposed the getter for UploadUri so it can be saved from the calling application.

    public Uri UploadUri { get; private set; }
    

提交回复
热议问题