Support inline PDF display or download via query param

Add a 'download' query parameter to DocResultController's GetAsync method. This lets clients choose whether to download the PDF or display it inline by setting the 'download' parameter in the request.
This commit is contained in:
2026-04-13 11:57:46 +02:00
parent f0f92c5400
commit 65d615f43e

View File

@@ -9,8 +9,13 @@ namespace EnvelopeGenerator.ServiceHost.Controllers;
public class DocResultController(IMediator mediator) : ControllerBase public class DocResultController(IMediator mediator) : ControllerBase
{ {
[HttpGet] [HttpGet]
public async Task<IActionResult> GetAsync([FromQuery] ReadSingleEnvelopeDocResultQuery query, CancellationToken cancel = default) public async Task<IActionResult> GetAsync([FromQuery] ReadSingleEnvelopeDocResultQuery query, [FromQuery] bool download = false, CancellationToken cancel = default)
{ {
return File(await mediator.Send(query, cancel), "application/pdf", $"envelope_{query.Envelope.Uuid}.pdf"); var bytes = await mediator.Send(query, cancel);
if (download)
return File(bytes, "application/pdf", $"envelope_{query.Envelope.Uuid}.pdf");
return File(bytes, "application/pdf");
} }
} }