title: java - how to send images from a RESTful web service?
body: <p>I'm implementing a <strong><em>Restful Web Service</em></strong> on <em>Java</em>, with no framework. My idea is to send images from a file server, because storing them on a database slows the server down. By the moment, I have the following code, which returns json content:</p>
  
  <pre><code>@Path("articulo")
  public class ArticuloResource {
  
      @Context
      private UriInfo context;
      private final ArticuloService service;
      private final Gson gson;
  
      /**
       * Creates a new instance of ArticuloResource
       */
      public ArticuloResource() {
          this.service = new ArticuloService();
          this.gson = new Gson();
      }
  
      /**
       * Retrieves representation of an instance of ArticuloResource
       * @return an instance of com.tienda.rest.pojo.Articulo
       */
      @GET
      @Produces(Metodos.Parametros.TYPE_APPLICATION_JSON)
      public String getJson() {
          return this.gson.toJson(this.service.seleccionarTodo());
      }    
  
      @GET
      @Path("novedades")
      @Produces(Metodos.Parametros.TYPE_APPLICATION_JSON)
      public String getNovedades() {
          return "Novedades";
      }
  
      @GET
      @Path("{id}")
      @Produces(Metodos.Parametros.TYPE_APPLICATION_JSON)
      public String getArticulo(@PathParam("id") Integer id) {
          return this.gson.toJson(this.service.getUnique(id));
      }
  
      /**
       * PUT method for updating or creating an instance of ArticuloResource
       * @param content representation for the resource
       * @return an HTTP response with content of the updated or created resource.
       */
      @PUT
      @Consumes(Metodos.Parametros.TYPE_APPLICATION_JSON)
      public void putJson(Articulo content) {
      }
  
      @GET
      @Produces(Metodos.Parametros.TYPE_IMAGE_PNG)
      public Response getImage() {
          return null;
      }
  }
  </code></pre>
  
  <p>Ideas? Thanks in advance.</p>