Skip to content

Commit

Permalink
fix: token added for send file operation callback method
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohit Tejani authored and Mohit Tejani committed Feb 25, 2025
1 parent c93c03f commit 1658bb0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Api/PubnubApi/EndPoint/Files/SendFileOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,13 @@ private void ProcessFileUpload(PNCallback<PNFileUploadResult> callback)
currentCryptoModule = !string.IsNullOrEmpty(currentFileCipherKey) ? new CryptoModule(new LegacyCryptor(currentFileCipherKey, true, pubnubLog), null) : (config.CryptoModule ??= new CryptoModule(new LegacyCryptor(config.CipherKey, true, pubnubLog), null));
}
byte[] postData = GetMultipartFormData(sendFileByteArray, generateFileUploadUrlResult.FileName, generateFileUploadUrlResult.FileUploadRequest.FormFields, dataBoundary, currentCryptoModule, config, pubnubLog);
CancellationTokenSource cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromMinutes(5));
var transportRequest = new TransportRequest() {
RequestType = Constants.POST,
RequestUrl = generateFileUploadUrlResult.FileUploadRequest.Url,
BodyContentBytes = postData,
CancellationTokenSource = cts
};
transportRequest.Headers.Add("Content-Type", contentType);
PubnubInstance.transportMiddleware.Send(transportRequest: transportRequest).ContinueWith(t => {
Expand Down Expand Up @@ -218,7 +221,7 @@ private void ProcessFileUpload(PNCallback<PNFileUploadResult> callback)
requestState.PubnubCallback.OnResponse(default, status);
}
}
});
}, cts.Token);
}

private async Task<PNResult<PNFileUploadResult>> ProcessFileUpload()
Expand Down Expand Up @@ -262,7 +265,7 @@ private async Task<PNResult<PNFileUploadResult>> ProcessFileUpload()
};
transportRequest.Headers.Add("Content-Type", contentType);
Tuple<string, PNStatus> jsonAndStatusTuple;
var transportResponse = await PubnubInstance.transportMiddleware.Send(transportRequest: transportRequest).ConfigureAwait(false);
var transportResponse = await PubnubInstance.transportMiddleware.Send(transportRequest: transportRequest);
if (transportResponse.StatusCode == 204 && transportResponse.Error == null) {
var responseString = "{}";
PNStatus errStatus = GetStatusIfError<PNFileUploadResult>(requestState, responseString);
Expand Down

0 comments on commit 1658bb0

Please sign in to comment.