Input and Output Binary Streams Using Jersey

How Jersey 2 Client can send Input/Output binary stream to Server and Vise Versa

This Question and its answers solved my problem. In the answers, InputStreams were used. They worked well, but I had to do some modifications to make them work for Jersey 2.8. Also, Instead of stream, direct byte [] also can be used. I tested and it worked well. Big thank to Martin Wilson and sikrip .

Jersey: Get binary data from post request

Answering myself...

It is very simple, the removal of @Consumes(MediaType.APPLICATION_OCTET_STREAM) solved the problem

Jersey Client post binary data application-octet/stream

I think you can invoke a POST request with Entity which encapsulates binary data like this:

Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target("http://example.com/rest");
Response response = webTarget.request(MediaType.TEXT_PLAIN_TYPE)
.post(Entity.entity("abc", MediaType.APPLICATION_OCTET_STREAM));

Form file uploads in jersey-client 1.18

I think this has already been answered. You should be using FormDataMultiPart

Jersey REST Client : Posting MultiPart data



Related Topics



Leave a reply



Submit