I use Jersey to create RESTful services, and currently I'm stuck on something that I thought should not be too heavy.
I will be able to upload the file that I want to download, but I do not know how to save it.
I searched the Internet for answers, but I did not find anything useful to fill the gaps in my knowledge.
Can you please give me a hit, how to proceed to save the file to a location on hdd? Any code samples would be much appreciated!
Client client = Client.create();
WebResource imageRetrievalResource = client
.resource("http://server/");
WebResource wr=imageRetrievalResource.path("instances/attachment");
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("item", "1");
Builder wb=wr.accept("application/json,text/html,application/xhtml+xml,application/xml");
client.addFilter(new HTTPBasicAuthFilter("user","pass"));
ClientResponse response= wr.queryParams(queryParams).get(ClientResponse.class);
String s= response.getEntity(String.class);
System.out.println(response.getStatus());
Thank!
karla source
share