Issue
I want to upload multipart file like here article. Here is my code
@RequestMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, method = {RequestMethod.POST, RequestMethod.PUT})
public Mono<ResponseEntity<UploadResult>> multipartUploadHandler(@RequestHeader HttpHeaders headers, @RequestBody Flux<Part> parts) {
return parts
.ofType(FilePart.class) // We'll ignore other data for now
.flatMap((part) -> saveFile(headers, s3config.getBucket(), part))
.collect(Collectors.toList())
.map((keys) -> ResponseEntity.status(HttpStatus.CREATED)
.body(new UploadResult(HttpStatus.CREATED, keys)));
}
But when I send a request, i get 415
What could be the problem?
Solution
Change @RequestBody Flux<Part> parts
to @RequestPart("file") Flux<FilePart> parts
fix all of this
Answered By - Argun
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)