@GET @Produces("application/zip") @Path("{itemId}") public Response downloadItem(@PathParam("itemId") int itemId){ String fileName = "item" + itemId + ".zip"; StreamingOutput streamingOutput = new StreamingOutput(){ public void write(OutputStream output) throws IOException, WebApplicationException { // write data to output stream here } }; return Response.ok(streamingOutput, "application/zip").header("content-disposition","attachment; filename = "+fileName).build(); } |
My online tech scrapbook where I keep my notes in case I need to look them up later
Monday, December 24, 2012
Jersey Server Binary File
To serve a binary file such as a ZIP file with a REST service in Jersey, use the following:
Labels:
jersey
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment