users@jersey.java.net

[Jersey] Re: Image As a Jersey Response

From: Joseph Mocker <jmocker_at_velti.com>
Date: Thu, 31 Jan 2013 16:08:29 +0000

This may be somewhat hacky, but what if you specify no @Produces at all then just set the content type in the Response with ResponseBuilder.type(…) ?

  --joe


[Velti]<http://www.velti.com> Joseph Mocker | Senior Software Architect
t +1.650.566.7033 m +1.408.676.6625
e jmocker@velti.com @Mobclix<http://twitter.com/Mobclix>
[cid:sep111c72902]
The leading global technology provider of
mobile marketing and advertising solutions


On Jan 30, 2013, at 10:02 PM, selvakumar netaji wrote:

Hi Joe,

I tried the above mentioned solution, it doesn't work for this service but with other data based rest services which adds the accept type (either JSON or XML) in the request works fine.

We cannot add the accept type in the request since the user is unaware of the response type, it depends on the data format stored in the database. Is there are any other alternatives.


On Thu, Jan 31, 2013 at 11:12 AM, selvakumar netaji <vvekselva.gm_at_gmail.com<mailto:vvekselva.gm_at_gmail.com>> wrote:
Hi Joe thanks for the reply. Will try this and reply you if I've any issues.


On Wed, Jan 30, 2013 at 11:15 PM, Joseph Mocker <jmocker_at_velti.com<mailto:jmocker_at_velti.com>> wrote:
The @Produces annotation can accept multiple MIME types as an array, for example @Produces({"images/gif", "images/png"})

 See http://docs.oracle.com/cd/E19226-01/820-7627/gipxf/index.html for more information. Would this work for you?

  --joe

Joseph Mocker | Velti | Senior Software Architect
t +1.650.566.7033 m +1.408.676.6625
e jmocker_at_velti.com<mailto:jmocker_at_velti.com> @Mobclix

The leading global technology provider of
mobile marketing and advertising solutions

On Jan 30, 2013, at 5:53 AM, selvakumar netaji wrote:

> Hi All,
>
> I've designed a rest service to upload a image of various formats. The service loads the image into the database..
>
> This works fine but the get service which retrieves the image creates the problem for me. I have annotated the get service as @Produces("image/png"), which works fine for png images stored in the database, If i annotate as @Produces("image/*") its not working for any of the images. Can you guide me to handle the situation to support all the images.








logo111821a35
(image/gif attachment: logo111821a35)

sep111c72902
(image/gif attachment: sep111c72902)