22 lines
690 B
C#
22 lines
690 B
C#
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);
|
|
}
|
|
} |