Merge pull request #166 from Sea-Haven-Industries/fix/ab/sh-383-mobile-video-upload
Some checks failed
Backend CI / Build and test (push) Has been cancelled
Backend CI / architecture (push) Has been cancelled
Backend CI / review (push) Has been cancelled
Backend CI / ci-complete (push) Has been cancelled

Allow mobile work order video uploads up to 200 MB
This commit is contained in:
Alexandre Brandizzi 2026-09-21 20:59:00 +00:00 • committed by GitHub
commit b36b69df83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 6 deletions

View file

@ -31,7 +31,7 @@ public class WorkOrderMediaControllerTests
}
[Fact]
public void AddMedia_HasFiftyMegabyteRequestLimit()
public void AddMedia_HasTwoHundredMegabyteRequestLimit()
{
var method = typeof(WorkOrderMediaController).GetMethod(nameof(WorkOrderMediaController.AddMedia));
var attribute = Assert.Single(
@ -39,14 +39,24 @@ public class WorkOrderMediaControllerTests
candidate => candidate.AttributeType == typeof(RequestSizeLimitAttribute));
var bytes = Assert.Single(attribute.ConstructorArguments);
Assert.Equal(50_000_000L, bytes.Value);
Assert.Equal(200_000_000L, bytes.Value);
}
[Fact]
public void AddMedia_HasTwoHundredMegabyteMultipartBodyLimit()
{
var method = typeof(WorkOrderMediaController).GetMethod(nameof(WorkOrderMediaController.AddMedia));
var attribute = Assert.IsType<RequestFormLimitsAttribute>(Assert.Single(
method!.GetCustomAttributes(typeof(RequestFormLimitsAttribute), inherit: true)));
Assert.Equal(200_000_000L, attribute.MultipartBodyLengthLimit);
}
[Fact]
public async Task AddMedia_FileOverLimit_ReturnsStableUnprocessableEntity()
{
var file = new Mock<IFormFile>();
file.SetupGet(candidate => candidate.Length).Returns(50_000_001);
file.SetupGet(candidate => candidate.Length).Returns(200_000_001);
var storage = new Mock<IFileStoragePort>(MockBehavior.Strict);
var controller = CreateController(storage: storage);
@ -55,7 +65,7 @@ public class WorkOrderMediaControllerTests
var response = Assert.IsType<UnprocessableEntityObjectResult>(result);
var error = Assert.IsType<WorkOrderBoardValidationErrorDto>(response.Value);
Assert.Equal("FileTooLarge", error.Code);
Assert.Equal("The uploaded file must not exceed 50 MB.", error.Message);
Assert.Equal("The uploaded file must not exceed 200 MB.", error.Message);
storage.VerifyNoOtherCalls();
}

View file

@ -17,7 +17,7 @@ namespace Api.SeaHavenIndustries.Controllers
[Route("api/workorders")]
public class WorkOrderMediaController : Controller
{
public const long MaxUploadBytes = 50_000_000;
public const long MaxUploadBytes = 200_000_000;
private readonly IWorkOrderMediaService _workOrderMediaService;
private readonly IFileStoragePort _fileStorage;
@ -75,6 +75,7 @@ namespace Api.SeaHavenIndustries.Controllers
[HttpPost("{id:int}/media")]
[RequestSizeLimit(MaxUploadBytes)]
[RequestFormLimits(MultipartBodyLengthLimit = MaxUploadBytes)]
public async Task<IActionResult> AddMedia(
int id,
[FromForm] WorkOrderMediaCategory? category,
@ -91,7 +92,7 @@ namespace Api.SeaHavenIndustries.Controllers
{
throw new WorkOrderBoardValidationException(
"FileTooLarge",
"The uploaded file must not exceed 50 MB.");
"The uploaded file must not exceed 200 MB.");
}
WorkOrderMediaFileRules.EnsureAllowed(file, category);