2

I'm working on a WebApp with Jersey and Grizzly.

I want to offer images for the clients by giving them the imageID and the imageURL. The clients also should have the possibility to send me images. So how can I host images with grizzly? And how should the @POST method look like.

EDIT Now I know how the @POST method should look like. This helped: How can I send a generic file to a jersey service and receive it correctly? But one question remains. How can I host the image with grizzly and provide a link to it.

EDIT Now I also know how to host images. http://jersey.java.net/nonav/documentation/latest/jax-rs.html#d4e322 Rest does this for me.

  1 @GET
  2 @Path("/images/{image}")
  3 @Produces("image/*")
  4 public Response getImage(@PathParam("image") String image) {
  5     File f = new File(image);
  6 
  7     if (!f.exists()) {
  8         throw new WebApplicationException(404);
  9     }
 10 
 11     String mt = new MimetypesFileTypeMap().getContentType(f);
 12     return Response.ok(f, mt).build();
 13 }
Community
  • 1
  • 1
jim810
  • 128
  • 2
  • 10

0 Answers0