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.
21 lines
689 B
C#
21 lines
689 B
C#
using EnvelopeGenerator.Application.Envelopes.Queries;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace EnvelopeGenerator.ServiceHost.Controllers;
|
|
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class DocResultController(IMediator mediator) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetAsync([FromQuery] ReadSingleEnvelopeDocResultQuery query, [FromQuery] bool download = false, CancellationToken cancel = default)
|
|
{
|
|
var bytes = await mediator.Send(query, cancel);
|
|
|
|
if (download)
|
|
return File(bytes, "application/pdf", $"envelope_{query.Envelope.Uuid}.pdf");
|
|
|
|
return File(bytes, "application/pdf");
|
|
}
|
|
} |