[backend/api] Fix emoji import request size limiter not being disabled
This commit is contained in:
parent
ed1623b572
commit
bcc8377bec
2 changed files with 29 additions and 1 deletions
|
@ -0,0 +1,28 @@
|
||||||
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
|
using Microsoft.AspNetCore.Http.Metadata;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
|
||||||
|
namespace Iceshrimp.Backend.Controllers.Shared.Attributes;
|
||||||
|
|
||||||
|
public class NoRequestSizeLimitAttribute : Attribute, IFormOptionsMetadata, IResourceFilter
|
||||||
|
{
|
||||||
|
public void OnResourceExecuting(ResourceExecutingContext context)
|
||||||
|
{
|
||||||
|
var feature = context.HttpContext.Features.Get<IHttpMaxRequestBodySizeFeature>() ??
|
||||||
|
throw new Exception("Failed to get IHttpMaxRequestBodySizeFeature");
|
||||||
|
feature.MaxRequestBodySize = long.MaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnResourceExecuted(ResourceExecutedContext context) { }
|
||||||
|
|
||||||
|
public bool? BufferBody => null;
|
||||||
|
public int? MemoryBufferThreshold => null;
|
||||||
|
public long? BufferBodyLengthLimit => long.MaxValue;
|
||||||
|
public int? ValueCountLimit => null;
|
||||||
|
public int? KeyLengthLimit => null;
|
||||||
|
public int? ValueLengthLimit => null;
|
||||||
|
public int? MultipartBoundaryLengthLimit => null;
|
||||||
|
public int? MultipartHeadersCountLimit => null;
|
||||||
|
public int? MultipartHeadersLengthLimit => null;
|
||||||
|
public long? MultipartBodyLengthLimit => long.MaxValue;
|
||||||
|
}
|
|
@ -187,7 +187,7 @@ public class EmojiController(
|
||||||
|
|
||||||
[HttpPost("import")]
|
[HttpPost("import")]
|
||||||
[Authorize("role:moderator")]
|
[Authorize("role:moderator")]
|
||||||
[DisableRequestSizeLimit]
|
[NoRequestSizeLimit]
|
||||||
[ProducesResults(HttpStatusCode.Accepted)]
|
[ProducesResults(HttpStatusCode.Accepted)]
|
||||||
public async Task<AcceptedResult> ImportEmoji(IFormFile file)
|
public async Task<AcceptedResult> ImportEmoji(IFormFile file)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue