[ADD] Added endpoint for providing files

This commit is contained in:
max
2025-09-22 16:15:18 +02:00
parent a478943792
commit 646e0a814a
3 changed files with 48 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
using Manager.App.Services;
using Microsoft.AspNetCore.Mvc;
namespace Manager.App.Controllers;
[ApiController]
[Route("api/v1/[controller]")]
public class FileController(ILibraryService libraryService) : ControllerBase
{
[HttpGet("provide")]
public async Task<IActionResult> ProvideFile([FromQuery(Name = "id")] Guid id, CancellationToken cancellationToken)
{
var fileResult = await libraryService.GetFileByIdAsync(id, cancellationToken);
if (!fileResult.IsSuccess)
{
return BadRequest(fileResult.Error);
}
var libFile = fileResult.Value;
return File(libFile.DataStream, libFile.MimeType, libFile.FileName);
}
}