I use CXF and Spring to create RESTful web services.
This is my problem: I want to create a service that creates "any" type of file (maybe an image, a document, txt or even a PDF), as well as XML. So far I have received this code:
@Path("/download/") @GET @Produces({"application/*"}) public CustomXML getFile() throws Exception;
I do not know where to start, please be patient.
EDIT:
Full Bryant Luke code (thanks!)
@Path("/download/") @GET public javax.ws.rs.core.Response getFile() throws Exception { if () { File file = new File("..."); return Response.ok(file, MediaType.APPLICATION_OCTET_STREAM) .header("content-disposition", "attachment; filename =" + file.getName()) .build(); } return Response.ok(new FileInputStream("custom.xml")).type("application/xml").build(); }
java rest binaryfiles cxf
Marco aviles
source share