Using Spring Boot 3.0.2 I'm doing this request similar to example in Spring docs
public Mono<String> createNode(@PathVariable String id,
@RequestParam MultipartFile fileData,
@RequestParam String name) {
return webClient.post()
.uri("/nodes/{id}", id)
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
.body(Flux.concat(
FormPartEvent.create("name", name),
FilePartEvent.create("fileData", fileData.getResource())
), PartEvent.class)
.retrieve()
.bodyToMono(String.class);
}
but i got following error:
ERROR 7704 --- [nio-8081-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.web.reactive.function.client.WebClientRequestException: MultipartFile resource [fileData] cannot be resolved to absolute file path] with root cause
java.io.FileNotFoundException: MultipartFile resource [fileData] cannot be resolved to absolute file path
at org.springframework.core.io.AbstractResource.getFile(AbstractResource.java:132) ~[spring-core-6.0.4.jar:6.0.4]
at org.springframework.http.codec.multipart.FilePartEvent.create(FilePartEvent.java:97) ~[spring-web-6.0.4.jar:6.0.4]
at org.springframework.http.codec.multipart.FilePartEvent.create(FilePartEvent.java:84) ~[spring-web-6.0.4.jar:6.0.4]
When I send multipart data using BodyInserters.fromMultipartData everything works correctly:
webClient.post()
.uri("/nodes/{id}", id)
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
.body(fromMultipartData("name", name).with("fileData", fileData.getResource()))
.retrieve()
.bodyToMono(String.class);
Shoudln't be use of PartEvent equivalent solution? What is different and why first one doesn't work?