0

我们正在尝试从 Java 代码上传 JAR 文件。在 EI 中通过文件传输的位置查看,我们可以看到 jar 文件,它以 JSON 格式而不是二进制格式以文本形式可读。

客户端代码:

ClientConfig clientConfig = new ClientConfig();
clientConfig.property(ClientProperties.CONNECT_TIMEOUT, 300000);
clientConfig.register(MultiPartFeature.class);
Client client = ClientBuilder.newClient(clientConfig);
HttpAuthenticationFeature authDetails = HttpAuthenticationFeature.basic(username, password);
client.register(authDetails);

MultiPart multiPart = new MultiPart();

FileDataBodyPart fileDataBodyPart = fileToSend != null? new FileDataBodyPart("file", fileToSend): new  FileDataBodyPart();
multiPart.bodyPart(fileDataBodyPart);

Response response = client.target(url).request().accept(MediaType.APPLICATION_JSON).header("filename", fileToSend.getName())
        .post(fileToSend != null? Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA) : null, Response.class);
return response.readEntity(String.class);

读取时在EI位置收到后的文件:

{"binary":"LS1Cb3VuZGFyeV8xXzYwNzg5NjaXNwb3Npd.........."}

但是,此问题仅发生在 WSO2 6.5.0 版本中,与 WSO2 6.1.1 一起使用时,相同的代码片段可以按预期正常工作。作为二进制(jar)传输的文件在 6.1.1 版本的 wso2 ei 中作为二进制(jar)接收/读取。

4

0 回答 0