mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Adds initial ASP.NET Core MVC replacement for Blazor WASM
This commit is contained in:
1 parent
5409200c7a
commit
193861c9c5
56 files changed
+505
-4139
No files matched your search
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Core.FileManagement.Thumbnails.Queries.GetThumbnail;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Presentation.Api.Common.ModelBinders;
|
||||
using Lumina.Presentation.Api.Common.Utilities;
|
||||
using Lumina.Presentation.Api.Core.Controllers.Common;
|
||||
using Mediator;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Controllers.FileManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Controller for managing file system items thumbnails.
|
||||
/// </summary>
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
public class ThumbnailsController : ApiController
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
private readonly ISender _mediator;
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ThumbnailsController"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediator">Injected service for mediating commands and queries.</param>
|
||||
public ThumbnailsController(ISender mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Gets the thumbnail of a file identified by of <paramref name="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the file for which to get the thumbnail.</param>
|
||||
/// <param name="quality">The quality to use for the thumbnail.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[HttpGet("get-thumbnail")]
|
||||
public async Task<IActionResult> GetThumbnail([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [FromQuery] int quality, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<ThumbnailResponse> getResult = await _mediator.Send(new GetThumbnailQuery(path, quality), cancellationToken);
|
||||
return getResult.Match(result => File(result.Bytes, MimeTypes.GetMimeType(result.Type)), errors => Problem(errors));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user