| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System.Security.Claims;
- using MediatR;
- using Microsoft.AspNetCore.Mvc;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.ChannelTitle;
- /// <summary>채널 칭호 아이콘 업로드 (이미지 전용 — gif, jpeg, png, webp / 최대 20MB)</summary>
- internal sealed class UploadChannelTitleIcon : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapPost("api/channel-titles/icon/upload", async (
- IFormFile file,
- [FromForm] int channelID,
- ClaimsPrincipal user,
- ISender sender,
- CancellationToken ct
- ) => {
- var memberID = user.GetMemberID();
- if (memberID is null)
- {
- return ApiResponse.Fail(StatusCodes.Status401Unauthorized, "Invalid token");
- }
- var result = await sender.Send(new Application.Features.Api.ChannelTitle.UploadIcon.Command(
- channelID,
- memberID.Value,
- file
- ), ct);
- return result.Match(
- url => ApiResponse.Ok(new { url }),
- CustomResults.Problem
- );
- })
- .WithTags("ChannelTitle")
- .RequireAuthorization()
- .DisableAntiforgery();
- }
- }
|