ByteArrayEntity should be what you are looking for:
[...] PostMethod post = new PostMethod(url); post.setRequestEntity(new ByteArrayEntity(bytes)); post.setRequestHeader("Content-type", "application/octet-stream"); [...]
You need to set the content-type to match what you have in the byte array.
source share