Ben jersey/JAX-RS uygulanması için yeni.Forma indirmek ve kaydetmek için Jersey client
Client client = Client.create();
WebResource wr = client.resource("http://localhost:7070/upload-0.0.1-SNAPSHOT/rest/files/download");
Builder wb=wr.accept("application/json,application/pdf,text/plain,image/jpeg,application/xml,application/vnd.ms-excel");
ClientResponse clientResponse= wr.get(ClientResponse.class);
System.out.println(clientResponse.getStatus());
File res= clientResponse.getEntity(File.class);
File downloadfile = new File("C://Data/test/downloaded/testnew.pdf");
res.renameTo(downloadfile);
FileWriter fr = new FileWriter(res);
fr.flush();
My Sunucu tarafı kodudur: dosyayı indirmek için benim forma istemci kod aşağıda bulabilirsiniz
müvekkilimin kodu ı 200 OK olarak tepkisini alıyorum, ama kurtarmak alamıyorum olarak@Path("/download")
@GET
@Produces({"application/pdf","text/plain","image/jpeg","application/xml","application/vnd.ms-excel"})
public Response getFile()
{
File download = new File("C://Data/Test/downloaded/empty.pdf");
ResponseBuilder response = Response.ok((Object)download);
response.header("Content-Disposition", "attachment; filename=empty.pdf");
return response.build();
}
Sabit diskteki dosyam Aşağıdaki satırda dosyaların kaydedilmesi gereken yol ve konumdan bahsediyorum. Burada neyin yanlış gittiğinden emin değil, herhangi bir yardım takdir edilecektir. Şimdiden teşekkürler!
File downloadfile = new File("C://Data/test/downloaded/testnew.pdf");
@GET yerine @POST ile yapmak mümkün mü? – spr
Kesinlikle öyle. Büyük ölçüde birbirleriyle değiştirilebilirler. Gönderiyi tercih ederim çünkü vücut sabitlenebilir ve parametreler görünmez (görünür olmamalıdır). –