Microsoft.OneDrive.Sdk.Helpers.ChunkedUploadProvider.UpdateSessionStatusAsync C# (CSharp) Method

UpdateSessionStatusAsync() public method

Get the status of the session. Stores returned session internally. Updates internal list of ranges remaining to be uploaded (according to the server).
public UpdateSessionStatusAsync ( ) : Task
return Task
        public virtual async Task<UploadSession> UpdateSessionStatusAsync()
        {
            var request = new UploadSessionRequest(this.Session, this.client, null);
            var newSession = await request.GetAsync();
            
            var newRangesRemaining = this.GetRangesRemaining(newSession);

            this.rangesRemaining = newRangesRemaining;
            newSession.UploadUrl = this.Session.UploadUrl; // Sometimes the UploadUrl is not returned
            this.Session = newSession;
            return newSession;
        }

Usage Example

        /// <inheritdoc/>
        public async Task <long> GetUploadStatusAsync()
        {
            if (_uploadProvider != null && IsUploadCompleted == false)
            {
                if (Provider.AuthenticationProvider is MsaAuthenticationProvider)
                {
                    var remainingRequests = _uploadProvider.GetUploadChunkRequests();
                    var firstChunck       = remainingRequests.First <OneDriveSdk.UploadChunkRequest>();
                    var status            = await _uploadProvider.UpdateSessionStatusAsync();

                    return(firstChunck.RangeBegin);
                }
            }

            // no more data
            return(0);
        }