Exemple #1
0
        /// <summary>
        /// Get the status of the session. Stores returned session internally.
        /// Updates internal list of ranges remaining to be uploaded (according to the server).
        /// </summary>
        /// <returns>UploadSession returned by the server.</returns>
        public virtual async Task <UploadSession> UpdateSessionStatusAsync()
        {
            var request    = new UploadSessionRequest(this.Session, this.client, null);
            var newSession = await request.GetAsync().ConfigureAwait(false);

            var newRangesRemaining = this.GetRangesRemaining(newSession);

            this.rangesRemaining = newRangesRemaining;
            newSession.UploadUrl = this.Session.UploadUrl; // Sometimes the UploadUrl is not returned
            this.Session         = newSession;
            return(newSession);
        }
Exemple #2
0
        /// <summary>
        /// Delete the session.
        /// </summary>
        /// <returns>Once returned task is complete, the session has been deleted.</returns>
        public async Task DeleteSessionAsync()
        {
            // validate that the upload can still be deleted.
            var uploadExpirationTime = this.Session.ExpirationDateTime ?? DateTimeOffset.Now;

            if (DateTimeOffset.Compare(uploadExpirationTime, DateTimeOffset.Now) <= 0)
            {
                throw new ClientException(
                          new Error
                {
                    Code    = ErrorConstants.Codes.Timeout,
                    Message = ErrorConstants.Messages.ExpiredUploadSession
                });
            }
            var request = new UploadSessionRequest(this.Session, this._client);
            await request.DeleteAsync().ConfigureAwait(false);
        }
Exemple #3
0
        /// <summary>
        /// Delete the session.
        /// </summary>
        /// <returns>Once returned task is complete, the session has been deleted.</returns>
        public async Task <UploadSession> DeleteSession()
        {
            var request = new UploadSessionRequest(this.Session, this.client, null);

            return(await request.DeleteAsync().ConfigureAwait(false));
        }