Skip to content

Instantly share code, notes, and snippets.

@eaiman-shoshi
Last active July 29, 2020 09:35
Show Gist options
  • Save eaiman-shoshi/c5482b2c977c32776a3040e4f16669a8 to your computer and use it in GitHub Desktop.
Save eaiman-shoshi/c5482b2c977c32776a3040e4f16669a8 to your computer and use it in GitHub Desktop.
@PostMapping(value = "/upload-multiValueMap", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_STREAM_JSON_VALUE)
@ResponseStatus(value = HttpStatus.OK)
public Mono<YourResponseClass> uploadFileMap(@RequestBody Mono<MultiValueMap<String, Part>> filePartMapMono) {
return filePartMapMono.flatMap(this::sendFile);
}
private Mono<YourResponseClass> sendFile (MultiValueMap<String, Part> filePartMap) {
return webClient.post()
.uri("YOUR_ENDPOINT")
.contentType(MediaType.MULTIPART_FORM_DATA)
.body(BodyInserters.fromMultipartData(filePartMap))
.retrieve()
.bodyToMono(YourResponseClass.class);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment