DRAB/Drab/FileController.cs
2025-07-11 00:18:14 +02:00

18 lines
470 B
C#

using Microsoft.AspNetCore.Mvc;
namespace Drab;
[ApiController]
public class FileController : ControllerBase
{
[HttpGet("/pdf/{filename}")]
public IActionResult Get([FromRoute] string filename)
{
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Orders", filename);
if (!System.IO.File.Exists(filePath))
return NotFound();
return File(System.IO.File.OpenRead(filePath), "application/pdf");
}
}