From d023f3586a77c23402bfa26fec5dfe73b4da4888 Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Tue, 1 Oct 2024 09:38:49 -0400 Subject: [PATCH] fix(dotnet): chunk upload --- templates/dotnet/Package/Client.cs.twig | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/templates/dotnet/Package/Client.cs.twig b/templates/dotnet/Package/Client.cs.twig index 685cf0bd7..fb6a3f50c 100644 --- a/templates/dotnet/Package/Client.cs.twig +++ b/templates/dotnet/Package/Client.cs.twig @@ -60,7 +60,7 @@ namespace {{ spec.title | caseUcfirst }} { _endpoint = endpoint; _http = http ?? new HttpClient(); - + _httpForRedirect = httpForRedirect ?? new HttpClient( new HttpClientHandler(){ AllowAutoRedirect = false @@ -220,7 +220,7 @@ namespace {{ spec.title | caseUcfirst }} public async Task Redirect( string method, - string path, + string path, Dictionary headers, Dictionary parameters) { @@ -269,7 +269,7 @@ namespace {{ spec.title | caseUcfirst }} var response = await _http.SendAsync(request); var code = (int)response.StatusCode; - if (response.Headers.TryGetValues("x-{{ spec.title | lower }}-warning", out var warnings)) + if (response.Headers.TryGetValues("x-{{ spec.title | lower }}-warning", out var warnings)) { foreach (var warning in warnings) { @@ -376,16 +376,23 @@ namespace {{ spec.title | caseUcfirst }} if (!string.IsNullOrEmpty(idParamName) && (string)parameters[idParamName] != "unique()") { + try + { // Make a request to check if a file already exists var current = await Call>( method: "GET", - path: "$path/${params[idParamName]}", - headers, - parameters = new Dictionary() + path: $"{path}/{parameters[idParamName]}", + new Dictionary { { "content-type", "application/json" } }, + parameters: new Dictionary() ); var chunksUploaded = (long)current["chunksUploaded"]; offset = chunksUploaded * ChunkSize; } + catch (Exception ex) + { + // ignored as it mostly means file not found + } + } while (offset < size) {