Sending binary data to the Restlet client

I am trying to send byte [] (using PUT) using Restlet, but I cannot find information on how to do this. My code is as follows:

Request request = new Request(Method.PUT, url); request.setEntity( WHAT DO I PUT HERE?, MediaType.APPLICATION_OCTET_STREAM); 

I was expecting to find something by ByteArrayRepresentation strings, just like JsonRepresentation and StringRepresentation, but I couldn't find anything.

+7
java rest put restlet
source share
3 answers

I believe you want to use InputRepresentation , for example:

 Representation representation = new InputRepresentation(new ByteArrayInputStream(bytes), MediaType.APPLICATION_OCTET_STREAM); request.setEntity(representation); 
+7
source share

I am not familiar with rezlit, but one way to do this is to encode base64 data. Then you can treat it like a regular string.

+1
source share

you can try a subclass of WritableRepresentation specifically designed for large presentations

+1
source share

All Articles