I can send binary data from a Restlet Client like so
Representation representation = new InputRepresentation(new ByteArrayInputStream(bytes), MediaType.APPLICATION_OCTET_STREAM);
request.setEntity(representation);
However, how can I receive this data from within a restlet ServerResouce?
My starting point would be a method with a signature like this?
@Put
public MyCustomResponse AddNewDocument(Form data)
{
...
}
But then how do I get the binary stream?
Try this:
@Put(MediaType.APPLICATION_OCTET_STREAM)
public MyCustomResponse AddNewDocument(Form data)
{
//...
}
If both your client and server are java+restlet I would suggest extracting it out to an interface if possible. This way, you could annotate the interface as above and both the client and server would use the same media type. Here is an example.
And here is the documentation for the PUT method: here. Although, it does seem to indicate that you don't necessarily want the full mime type, so you may have to dig around to find it or register it yourself (though it would seem this is already registered).