private async void OnGetUploadLinkCompleted(LiveOperationResult result) { if (result.Error != null) { this.taskCompletionSource.SetException(result.Error); return; } var uploadUrl = new Uri(result.RawResult, UriKind.Absolute); // NOTE: the GetUploadLinkOperation will return a uri with the overwite, suppress_response_codes, // and suppress_redirect query parameters set. Debug.Assert(uploadUrl.Query != null); Debug.Assert(uploadUrl.Query.Contains(QueryParameters.Overwrite)); Debug.Assert(uploadUrl.Query.Contains(QueryParameters.SuppressRedirects)); Debug.Assert(uploadUrl.Query.Contains(QueryParameters.SuppressResponseCodes)); var uploader = new BackgroundUploader(); uploader.Group = LiveConnectClient.LiveSDKUploadGroup; if (this.LiveClient.Session != null) { uploader.SetRequestHeader( ApiOperation.AuthorizationHeader, AuthConstants.BearerTokenType + " " + this.LiveClient.Session.AccessToken); } uploader.SetRequestHeader(ApiOperation.LibraryHeader, Platform.GetLibraryHeaderValue()); uploader.Method = HttpMethods.Put; UploadOperation uploadOperation; if (this.InputStream != null) { uploadOperation = await uploader.CreateUploadFromStreamAsync(uploadUrl, this.InputStream); } else { uploadOperation = uploader.CreateUpload(uploadUrl, this.InputFile); } this.taskCompletionSource.SetResult(new LiveUploadOperation(uploadOperation)); }