/// <summary>
        /// Completes a streamed upload.
        /// </summary>
        /// <param name="uploadProgress">The upload progress.</param>
        /// <returns>The updated <see cref="BatchUploadProgress"/> object.</returns>
        public BatchUploadProgress EndStreamUpload(BatchUploadProgress uploadProgress)
        {
            // Upload the postamble to mark the end of upload.
            List <byte> bytes = new List <byte>(Encoding.UTF8.GetBytes(POSTAMBLE));

            long totalUploadSize = (uploadProgress.BytesUploaded + bytes.Count);

            Upload(uploadProgress.Url, bytes.ToArray(), uploadProgress.BytesUploaded, totalUploadSize);
            uploadProgress.BytesUploaded += bytes.Count;
            return(uploadProgress);
        }
        /// <summary>
        /// Performs a streamed upload.
        /// </summary>
        /// <param name="uploadProgress">The upload progress.</param>
        /// <param name="postBody">The post body to be stream uploaded.</param>
        /// <returns>The updated <see cref="BatchUploadProgress"/> object.</returns>
        protected BatchUploadProgress StreamUpload(BatchUploadProgress uploadProgress,
                                                   string postBody)
        {
            string payloadToUpload = GetPayload(uploadProgress.BytesUploaded, postBody);

            // Pad the payload to match a block boundary.
            List <byte> bytes     = new List <byte>(Encoding.UTF8.GetBytes(payloadToUpload));
            int         padLength = CHUNK_SIZE_ALIGN - (bytes.Count % CHUNK_SIZE_ALIGN);
            string      padding   = new String(' ', padLength);

            bytes.AddRange(Encoding.UTF8.GetBytes(padding));

            // Since we don't know the totalUploadSize at this point, we pass a null
            // instead.
            Upload(uploadProgress.Url, bytes.ToArray(), uploadProgress.BytesUploaded, null);
            uploadProgress.BytesUploaded += bytes.Count;
            return(uploadProgress);
        }