Skip to content

Commit

Permalink
Merge branch 'test'
Browse files Browse the repository at this point in the history
  • Loading branch information
neophyte57 committed Aug 23, 2024
2 parents d83c3c3 + 6fa0f38 commit fe5abdc
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using Flurl;
using Microsoft.Extensions.Logging;

using Prime.Extensions;
using Prime.HttpClients.DocumentManagerApiDefinitions;
Expand All @@ -13,11 +14,14 @@ namespace Prime.HttpClients
public class DocumentManagerClient : IDocumentManagerClient
{
private readonly HttpClient _client;
private readonly ILogger _logger;

public DocumentManagerClient(HttpClient httpClient)

public DocumentManagerClient(HttpClient httpClient, ILogger<DocumentManagerClient> logger)
{
// Credentials and Base Url are set in Startup.cs
_client = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
_logger = logger;
}

public async Task<HttpResponseMessage> InitializeUploadAsync(string filename, string fileSize)
Expand Down Expand Up @@ -59,7 +63,15 @@ public async Task<Guid> SendFileAsync(Stream document, string filename, string d
folder = destinationFolder
});

_client.Timeout = TimeSpan.FromMinutes(5);
try
{
_client.Timeout = TimeSpan.FromMinutes(5);
}
catch (InvalidOperationException e)
{
// Likely "System.InvalidOperationException: This instance has already started one or more requests. Properties can only be modified before sending the first request."
_logger.LogDebug(e.Message);
}

var response = await _client.PostAsync(url, new StreamContent(document));
var documentResponse = await response.Content.ReadAsAsync<DocumentGuidResponse>();
Expand Down

0 comments on commit fe5abdc

Please sign in to comment.