-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from GeneriekPublicatiePlatformWoo/106-perfor…
…mance-verbeteringen-voor-download/upload feat: streamen bij upload/download, timeout configurabel
- Loading branch information
Showing
7 changed files
with
63 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
ODPC.Server/Features/Documenten/UploadBestandsdeel/UploadBestandsdeelController.cs
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
ODPC.Server/Features/Documenten/UploadBestandsdeel/UploadBestandsdeelEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using ODPC.Apis.Odrc; | ||
|
||
namespace ODPC.Features.Documenten.UploadBestandsdeel | ||
{ | ||
public class UploadBestandsdeelEndpoint | ||
{ | ||
public static void Map(IEndpointRouteBuilder builder) => builder.MapPut( | ||
"api/{version}/documenten/{docUuid:guid}/bestandsdelen/{partUuid:guid}", | ||
async (HttpRequest request, IOdrcClientFactory clientFactory, IConfiguration config, CancellationToken token) => | ||
{ | ||
using var client = clientFactory.Create("Upload bestandsdeel"); | ||
var timeoutInMinutes = int.TryParse(config["UPLOAD_TIMEOUT_MINUTES"], out var m) | ||
? m | ||
: 10; | ||
client.Timeout = TimeSpan.FromMinutes(timeoutInMinutes); | ||
|
||
using var content = new StreamContent(request.Body); | ||
content.Headers.Add("Content-Type", request.Headers.ContentType.AsEnumerable()); | ||
content.Headers.ContentLength = request.Headers.ContentLength; | ||
|
||
using var requestMessage = new HttpRequestMessage(HttpMethod.Put, request.Path); | ||
requestMessage.Content = content; | ||
using var response = await client.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead, token); | ||
|
||
response.EnsureSuccessStatusCode(); | ||
return Results.NoContent(); | ||
}) | ||
.WithMetadata(new DisableRequestSizeLimitAttribute()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters