Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi Steve - sorry about the delay. You should be able to set custom headers with the JAX-RS client using the header() method, though I'm only going by the docs here, not having used it myself: http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/client/WebResource.html

However, for an image upload, there's a much bigger issue, which is that your client library really has to be designed not to buffer the entire posted data (i.e. the image) in memory first. I did dig through the Jersey source code to try to see whether this was the case, it looks like it could be OK, but you _may_ have to provider a custom adapter.

Personally, I would use a lower-level library for image upload & download. Apache HttpClient seems to have changed everything in v4, but here's a sample which explains how to do chunked uploading without buffering (apparently), it also references using a "FileEntity" class which I presume is exactly what you actually want... http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java