79549618

Date: 2025-04-02 03:47:29
Score: 1
Natty:
Report link

I got it working. There are two things that I was missing:

  1. Thanks to @Tiny Wang: the for loop has to be used with of and not in.
.ts

// 
for (let file of this.supportDocuments) {
 // file is a blob object
 formData.append("files", file);
}

this.uploadService.uploadFiles(formData)
  1. @Yong Sun suggested to use IFormFileCollection and it works, not sure why List does not, even though it is documented on Microsoft page.
routeBuilder.MapPost("api/cancellationforms/upload", 
    (IFormFileCollection files, 
    [FromServices] IServiceManager serviceManager, 
    CancellationToken cancellationToken) =>
{
    // Iterate each file if needed
    foreach (IFormFile file in files)
    {

    }

    return Results.Ok("Hello");
})
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Tiny
  • User mentioned (0): @Yong
  • Self-answer (0.5):
Posted by: Hoang Minh