This commit is contained in:
@@ -36,7 +36,7 @@ namespace AyaNova.Api.Controllers
|
||||
private readonly AyContext ct;
|
||||
private readonly ILogger<LogoController> log;
|
||||
private readonly ApiServerState serverState;
|
||||
private const int MAXIMUM_LOGO_SIZE = 512000;//We really don't want it too big or it will slow the fuck down for everything
|
||||
// private const int MAXIMUM_LOGO_SIZE = 512000;//We really don't want it too big or it will slow the fuck down for everything
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -114,8 +114,8 @@ namespace AyaNova.Api.Controllers
|
||||
[Authorize]
|
||||
[HttpPost("{size}")]
|
||||
//[DisableFormValueModelBinding]
|
||||
[RequestSizeLimit(MAXIMUM_LOGO_SIZE)]//currently export file is 200kb * 50 maximum at a time = 15mb https://github.com/aspnet/Announcements/issues/267
|
||||
public async Task<IActionResult> UploadAsync([FromRoute] string size)//, List<IFormFile> files /// <param name="files">Logo image file</param>
|
||||
[RequestSizeLimit(ServerBootConfig.MAX_LOGO_UPLOAD_BYTES)]
|
||||
public async Task<IActionResult> UploadAsync([FromRoute] string size)
|
||||
{
|
||||
|
||||
//https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-3.1#upload-small-files-with-buffered-model-binding-to-a-database
|
||||
@@ -148,8 +148,8 @@ namespace AyaNova.Api.Controllers
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await file.CopyToAsync(memoryStream);
|
||||
if (memoryStream.Length > MAXIMUM_LOGO_SIZE)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, null, $"Logo files must be smaller than {MAXIMUM_LOGO_SIZE} maximum"));
|
||||
if (memoryStream.Length > ServerBootConfig.MAX_LOGO_UPLOAD_BYTES)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, null, $"Logo files must be smaller than {ServerBootConfig.MAX_LOGO_UPLOAD_BYTES} maximum"));
|
||||
switch (size)
|
||||
{
|
||||
case "small":
|
||||
|
||||
Reference in New Issue
Block a user