Jar file transported to WSO2 EI using a custom endpoint is received with JSON content under a jar extension

58 views Asked by At

We are trying to upload a JAR file from the Java Code. On the Seeing through the location in which the file transferred in EI, We could see the jar file which is readable in text as JSON instead of a binary.

Client Side Code:

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);

File after received in the EI location when read:

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

However This issue is exclusively happening with the WSO2 6.5.0 version where as the same code snippet when used with WSO2 6.1.1 works fairly as per expectation. The file transported as binary(jar) is received/read as binary(jar) in wso2 ei in 6.1.1 version.

0

There are 0 answers