Solved: POST Payload does not arrive when posting file to RestController

I just had a RestController that worked correctly in the simplest possible Spring Boot project without Vaadin Fusion and Spring Security, but not in my Fusion v19.0.0.alpha5 project with Spring Security configured.

When I did an upload via curl (curl -F file=@"./bulk_upload.csv" https://localhost/api/example/upload/), the file part could be found.

Client error:
HTTP Status 400 – Bad Request

Server error:
2021-02-06 17:37:52.204 WARN 9009 --- [-nio-443-exec-5] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'file' is not present]

In the security configuration, for the moment I bypassed, just to get it working:

public SecurityConfiguration {
...
@Override
protected void configure(HttpSecurity http) {
  http
    .csrf()
      .ignoringAntMatchers("/api/supporter/**")
    .and()
      .authorizeRequests()
        .antMatchers("/api/supporter/**").permitAll()
    ...    
	}

The controller looks straightforward as follows:

@RestController
public class ExampleController {

    @PostMapping(value = "/api/example/upload")
    public ResponseEntity<?> uploadFile(@RequestParam("file") MultipartFile uploadfile) {

        if (uploadfile.isEmpty()) {
            return new ResponseEntity("Could not find file!", HttpStatus.OK);
        }
        else {
            System.out.println("Received file: " + uploadfile.toString());
        }

        try {
            saveUploadedFiles(Arrays.asList(uploadfile));

        } catch (IOException e) {
            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
        }

        return new ResponseEntity("Successfully uploaded - " +
                uploadfile.getOriginalFilename(), new HttpHeaders(), HttpStatus.OK);
    }
}

Turns out that the following configuration addition fixed the problem:

@Configuration
public class UploadConfig {

    @Bean
    public CommonsMultipartResolver multipartResolver() {
        CommonsMultipartResolver multipart = new CommonsMultipartResolver();
        multipart.setMaxUploadSize(3 * 1024 * 1024);
        return multipart;
    }

    @Bean
    public MultipartFilter multipartFilter() {
        MultipartFilter multipartFilter = new MultipartFilter();
        multipartFilter.setMultipartResolverBeanName("multipartResolver");
        return multipartFilter;
    }
}

Perhaps future occurrence of this issue can be avoided with a config change in Fusion?

In any case, I hope this post helps someone.