I'm trying to make a post with form data, containing only a file, but when I test the endpoint with Postman I get this error message:
Invalid mime type "File": does not contain '/'
Here is the server side (Spring Webflux). Endpoint:
@PostMapping(value ="/newUpload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_NDJSON_VALUE)
@ResponseStatus(value = HttpStatus.OK)
public Mono<List<String>> upload (@RequestPart("file") FilePart filePartMono){
return exampleRepository.getLines(filePartMono).collectList();
}
Service:
@Override
public Flux<String> getLines (FilePart filePartMono){
return filePartMono.content()
.map(dataBuffer -> {
byte[] bytes = new byte[dataBuffer.readableByteCount()];
dataBuffer.read(bytes);
DataBufferUtils.release(dataBuffer);
return new String(bytes, StandardCharsets.UTF_8);
})
.map(this::processAndGetLinesAsList)
.flatMapIterable(Function.identity());
}
private List<String> processAndGetLinesAsList (String string){
Supplier<Stream<String>> streamSupplier = string::lines;
var isFileOk = streamSupplier.get().allMatch(line ->
line.matches(MultipartFileUploadUtils.REGEX_RULES));
return isFileOk ? streamSupplier.get()
.filter(s -> !s.isBlank())
.collect(Collectors.toList()) : new ArrayList<>();
}
In postman I have in form-data the required file and the default headers:

Does anyone have any idea why the problem mentioned at the beginning may be happening?