79557539

Date: 2025-04-05 21:35:25
Score: 1
Natty:
Report link

Only after set options:

builder.setCharset(StandardCharsets.UTF_8);
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);

"name" sent correctly, and does not turn into "????? ?????".

*org.apache.httpcomponents httpclient version 4.5.14

Full code of using MultipartEntityBuilder with UTF-8:

var filePath = Path.of("<CyryllicFileName>");
var contentType = ContentType.TEXT_PLAIN.withCharset("UTF-8");
var builder = MultipartEntityBuilder.create();
builder.setCharset(StandardCharsets.UTF_8);
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
var entity = builder
        .addTextBody("name", name, contentType)
        .addBinaryBody("file",
                       filePath.toFile(),
                       ContentType.APPLICATION_OCTET_STREAM,
                       filePath.toFile().getName())
        .addTextBody("collectionId", collectionId)
        .addTextBody("parentDocumentId", parentDocumentId)
        .addTextBody("publish", "true")
        .build();
Reasons:
  • Blacklisted phrase (1): ???
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: PureTruth