0

i am trying to send a POST Request to the following Controller:

@ApiOperation(value = "Transfers a document to the configured document management systems")
  @PostMapping(value = "api/v1/document", produces = MediaType.APPLICATION_JSON_VALUE, consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE})
  public Flux<DmsWriteResponse> writeDocument(
          final @RequestPart("document") @Valid @NotNull Mono<FilePart> document,
          final @RequestPart("metadata")
          @ApiParam(value = "JSON-Object as described in FileMetadataImpl. Swagger needs this as a file upload...")
          @Parameter(name = "metadata", schema = @Schema(name = "metadata", type = "string", format = "binary"))
          @Valid @NotNull Mono<FileMetadataImpl> metadata,
          final @RequestParam(value = "dmsName", required = false) String dmsName) {

The curl request i am sending starts like this:

curl -X POST --location "http://localhost:8080/api/v1/document" \
    -H "Content-Type: multipart/form-data; charset=UTF-8; boundary=---------------------------735323031399963166993862150" \
    -F "document=@C:\stuff\Certificate-testü.pdf;filename=Certificate-testü.pdf;type=application/pdf" \
    -F "metadata={
  "person": "Ülülü ägägä"
};type=application/json" \
    --basic --user test:test

The weird thing is that the special characters inside the metadata object "Ülülü ägägä" are encoded correcetly but in the filename "Certificate-testü.pdf" the ü always gets read as Unicode character 65533 aka the replacement character. How do i read the ü correctly in the filename? I am reading the filename via

document.share().block().filename()
  • Check here. https://stackoverflow.com/questions/546365/utf-8-text-is-garbled-when-form-is-posted-as-multipart-form-data. Already discussed this. – Krishna Dec 15 '21 at 13:42

0 Answers0