You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by mauro2java2011 <ma...@gmail.com> on 2014/04/10 10:00:10 UTC

how stream a image from a web service apache cxf ?

http://
http://www.javatips.net/blog/2013/06/download-image-file-using-cxf-rest-jax-rs
<http://
http://www.javatips.net/blog/2013/06/download-image-file-using-cxf-rest-jax-rs>  


The above tutorial show how download a file image from webservice apache
rest cxf.

but it permit to make save file on device client like saveAs .

i would know how get a image for visualise it into a web page with using the
call at webservice .

I think that i have to stream the image and not set the content- disposition
from the method into web service?

Do you have a link for ot or suggestions...?







--
View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
then it depends, personally i was generating it on the fly through
ImageIO but since you have an outputstream you just basically copy the
stream of the image.
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-10 10:15 GMT+02:00 mauro2java2011 <ma...@gmail.com>:
> Ok but into method write (OutputStream output)  i have to pass a
> ByteArrayOutputStream if i get a byte[] for example from a entity jpa saved
> into db ?
>
> And if i get the image from a file saved into a dir on server i have to pass
> a FileOutputStream?
>
>
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668694.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by mauro2java2011 <ma...@gmail.com>.
tank you .
 Il giorno 20/apr/2014 11.32, "Romain Manni-Bucau [via OpenEJB]" <
ml-node+s979440n4668918h33@n4.nabble.com> ha scritto:

>
> http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/Response.ResponseBuilder.html#type(javax.ws.rs.core.MediaType)
>
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-04-20 11:09 GMT+02:00 mauro2java2011 <[hidden email]<http://user/SendEmail.jtp?type=node&node=4668918&i=0>>:
>
>
> > Response.ok method what it is ? whi method it is named ok ?
> > Il giorno 20/apr/2014 10.54, "Romain Manni-Bucau [via OpenEJB]" <
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4668918&i=1>>
> ha scritto:
> >
> >> write your bytes in out and set content type on Response.
> >>
> >>
> >> Romain Manni-Bucau
> >> Twitter: @rmannibucau
> >> Blog: http://rmannibucau.wordpress.com/
> >> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >> Github: https://github.com/rmannibucau
> >>
> >>
> >> 2014-04-20 10:48 GMT+02:00 mauro2java2011 <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=4668916&i=0>>:
> >>
> >>
> >> > 1) it is passd automaticalli from rest ?
> >> > 2) so inside the method write i can pass the ByteArrayOutputStream
> that
> >> > wrap the bites of image ?
> >> > 3) tge content type that i get from my db it is set in what section
> of
> >> code
> >> > ?
> >> > 4) i return a ibject of type Response ?
> >> > Il giorno 20/apr/2014 10.04, "Romain Manni-Bucau [via OpenEJB]" <
> >> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4668916&i=1>>
>
> >> ha scritto:
> >> >
> >> >> it is the jaxrs out stream, (more or less servlet outputstream)
> >> >>
> >> >> just write inside
> >> >>
> >> >>
> >> >> Romain Manni-Bucau
> >> >> Twitter: @rmannibucau
> >> >> Blog: http://rmannibucau.wordpress.com/
> >> >> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >> >> Github: https://github.com/rmannibucau
> >> >>
> >> >>
> >> >> 2014-04-20 9:55 GMT+02:00 mauro2java2011 <[hidden email]<
> >> http://user/SendEmail.jtp?type=node&node=4668914&i=0>>:
> >> >>
> >> >>
> >> >> > i have found the page :
> >> >> >
> >> >> > http://java.dzone.com/articles/jax-rs-streaming-response
> >> >> >
> >> >> >
> >> >> > into the @Override of method write(OutupStream out){
> >> >> >
> >> >> > }
> >> >> >
> >> >> > it is used the object out but i not understand do  it came from .
> >> >> >
> >> >> > in the example it  not is referencued  externally  any method
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > --
> >> >> > View this message in context:
> >> >>
> >>
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668913.html
> >> >> > Sent from the OpenEJB User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >> ------------------------------
> >> >>  If you reply to this email, your message will be added to the
> >> discussion
> >> >> below:
> >> >>
> >> >>
> >>
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668914.html
> >> >>  To unsubscribe from how stream a image from a web service apache
> cxf
> >> ?, click
> >> >> here<
> >> >> .
> >> >> NAML<
> >>
> http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> >>
> >> >>
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > View this message in context:
> >>
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668915.html
> >> > Sent from the OpenEJB User mailing list archive at Nabble.com.
> >>
> >>
> >> ------------------------------
> >>  If you reply to this email, your message will be added to the
> discussion
> >> below:
> >>
> >>
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668916.html
> >>  To unsubscribe from how stream a image from a web service apache cxf
> ?, click
> >> here<
> >> .
> >> NAML<
> http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> >>
> >
> >
> >
> >
> > --
> > View this message in context:
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668917.html
> > Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668918.html
>  To unsubscribe from how stream a image from a web service apache cxf ?, click
> here<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4668691&code=bWF1cm8yamF2YTIwMTFAZ21haWwuY29tfDQ2Njg2OTF8LTExMTcxODc2MjU=>
> .
> NAML<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668919.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/Response.ResponseBuilder.html#type(javax.ws.rs.core.MediaType)


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-20 11:09 GMT+02:00 mauro2java2011 <ma...@gmail.com>:
> Response.ok method what it is ? whi method it is named ok ?
> Il giorno 20/apr/2014 10.54, "Romain Manni-Bucau [via OpenEJB]" <
> ml-node+s979440n4668916h71@n4.nabble.com> ha scritto:
>
>> write your bytes in out and set content type on Response.
>>
>>
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>> 2014-04-20 10:48 GMT+02:00 mauro2java2011 <[hidden email]<http://user/SendEmail.jtp?type=node&node=4668916&i=0>>:
>>
>>
>> > 1) it is passd automaticalli from rest ?
>> > 2) so inside the method write i can pass the ByteArrayOutputStream that
>> > wrap the bites of image ?
>> > 3) tge content type that i get from my db it is set in what section of
>> code
>> > ?
>> > 4) i return a ibject of type Response ?
>> > Il giorno 20/apr/2014 10.04, "Romain Manni-Bucau [via OpenEJB]" <
>> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4668916&i=1>>
>> ha scritto:
>> >
>> >> it is the jaxrs out stream, (more or less servlet outputstream)
>> >>
>> >> just write inside
>> >>
>> >>
>> >> Romain Manni-Bucau
>> >> Twitter: @rmannibucau
>> >> Blog: http://rmannibucau.wordpress.com/
>> >> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> >> Github: https://github.com/rmannibucau
>> >>
>> >>
>> >> 2014-04-20 9:55 GMT+02:00 mauro2java2011 <[hidden email]<
>> http://user/SendEmail.jtp?type=node&node=4668914&i=0>>:
>> >>
>> >>
>> >> > i have found the page :
>> >> >
>> >> > http://java.dzone.com/articles/jax-rs-streaming-response
>> >> >
>> >> >
>> >> > into the @Override of method write(OutupStream out){
>> >> >
>> >> > }
>> >> >
>> >> > it is used the object out but i not understand do  it came from .
>> >> >
>> >> > in the example it  not is referencued  externally  any method
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > View this message in context:
>> >>
>> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668913.html
>> >> > Sent from the OpenEJB User mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ------------------------------
>> >>  If you reply to this email, your message will be added to the
>> discussion
>> >> below:
>> >>
>> >>
>> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668914.html
>> >>  To unsubscribe from how stream a image from a web service apache cxf
>> ?, click
>> >> here<
>> >> .
>> >> NAML<
>> http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>> >>
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668915.html
>> > Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668916.html
>>  To unsubscribe from how stream a image from a web service apache cxf ?, click
>> here<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4668691&code=bWF1cm8yamF2YTIwMTFAZ21haWwuY29tfDQ2Njg2OTF8LTExMTcxODc2MjU=>
>> .
>> NAML<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668917.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by mauro2java2011 <ma...@gmail.com>.
Response.ok method what it is ? whi method it is named ok ?
Il giorno 20/apr/2014 10.54, "Romain Manni-Bucau [via OpenEJB]" <
ml-node+s979440n4668916h71@n4.nabble.com> ha scritto:

> write your bytes in out and set content type on Response.
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-04-20 10:48 GMT+02:00 mauro2java2011 <[hidden email]<http://user/SendEmail.jtp?type=node&node=4668916&i=0>>:
>
>
> > 1) it is passd automaticalli from rest ?
> > 2) so inside the method write i can pass the ByteArrayOutputStream that
> > wrap the bites of image ?
> > 3) tge content type that i get from my db it is set in what section of
> code
> > ?
> > 4) i return a ibject of type Response ?
> > Il giorno 20/apr/2014 10.04, "Romain Manni-Bucau [via OpenEJB]" <
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4668916&i=1>>
> ha scritto:
> >
> >> it is the jaxrs out stream, (more or less servlet outputstream)
> >>
> >> just write inside
> >>
> >>
> >> Romain Manni-Bucau
> >> Twitter: @rmannibucau
> >> Blog: http://rmannibucau.wordpress.com/
> >> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >> Github: https://github.com/rmannibucau
> >>
> >>
> >> 2014-04-20 9:55 GMT+02:00 mauro2java2011 <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=4668914&i=0>>:
> >>
> >>
> >> > i have found the page :
> >> >
> >> > http://java.dzone.com/articles/jax-rs-streaming-response
> >> >
> >> >
> >> > into the @Override of method write(OutupStream out){
> >> >
> >> > }
> >> >
> >> > it is used the object out but i not understand do  it came from .
> >> >
> >> > in the example it  not is referencued  externally  any method
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > View this message in context:
> >>
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668913.html
> >> > Sent from the OpenEJB User mailing list archive at Nabble.com.
> >>
> >>
> >> ------------------------------
> >>  If you reply to this email, your message will be added to the
> discussion
> >> below:
> >>
> >>
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668914.html
> >>  To unsubscribe from how stream a image from a web service apache cxf
> ?, click
> >> here<
> >> .
> >> NAML<
> http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> >>
> >
> >
> >
> >
> > --
> > View this message in context:
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668915.html
> > Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668916.html
>  To unsubscribe from how stream a image from a web service apache cxf ?, click
> here<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4668691&code=bWF1cm8yamF2YTIwMTFAZ21haWwuY29tfDQ2Njg2OTF8LTExMTcxODc2MjU=>
> .
> NAML<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668917.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
write your bytes in out and set content type on Response.


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-20 10:48 GMT+02:00 mauro2java2011 <ma...@gmail.com>:
> 1) it is passd automaticalli from rest ?
> 2) so inside the method write i can pass the ByteArrayOutputStream that
> wrap the bites of image ?
> 3) tge content type that i get from my db it is set in what section of code
> ?
> 4) i return a ibject of type Response ?
> Il giorno 20/apr/2014 10.04, "Romain Manni-Bucau [via OpenEJB]" <
> ml-node+s979440n4668914h9@n4.nabble.com> ha scritto:
>
>> it is the jaxrs out stream, (more or less servlet outputstream)
>>
>> just write inside
>>
>>
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>> 2014-04-20 9:55 GMT+02:00 mauro2java2011 <[hidden email]<http://user/SendEmail.jtp?type=node&node=4668914&i=0>>:
>>
>>
>> > i have found the page :
>> >
>> > http://java.dzone.com/articles/jax-rs-streaming-response
>> >
>> >
>> > into the @Override of method write(OutupStream out){
>> >
>> > }
>> >
>> > it is used the object out but i not understand do  it came from .
>> >
>> > in the example it  not is referencued  externally  any method
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668913.html
>> > Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668914.html
>>  To unsubscribe from how stream a image from a web service apache cxf ?, click
>> here<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4668691&code=bWF1cm8yamF2YTIwMTFAZ21haWwuY29tfDQ2Njg2OTF8LTExMTcxODc2MjU=>
>> .
>> NAML<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668915.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by mauro2java2011 <ma...@gmail.com>.
1) it is passd automaticalli from rest ?
2) so inside the method write i can pass the ByteArrayOutputStream that
wrap the bites of image ?
3) tge content type that i get from my db it is set in what section of code
?
4) i return a ibject of type Response ?
Il giorno 20/apr/2014 10.04, "Romain Manni-Bucau [via OpenEJB]" <
ml-node+s979440n4668914h9@n4.nabble.com> ha scritto:

> it is the jaxrs out stream, (more or less servlet outputstream)
>
> just write inside
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-04-20 9:55 GMT+02:00 mauro2java2011 <[hidden email]<http://user/SendEmail.jtp?type=node&node=4668914&i=0>>:
>
>
> > i have found the page :
> >
> > http://java.dzone.com/articles/jax-rs-streaming-response
> >
> >
> > into the @Override of method write(OutupStream out){
> >
> > }
> >
> > it is used the object out but i not understand do  it came from .
> >
> > in the example it  not is referencued  externally  any method
> >
> >
> >
> >
> > --
> > View this message in context:
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668913.html
> > Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668914.html
>  To unsubscribe from how stream a image from a web service apache cxf ?, click
> here<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4668691&code=bWF1cm8yamF2YTIwMTFAZ21haWwuY29tfDQ2Njg2OTF8LTExMTcxODc2MjU=>
> .
> NAML<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668915.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
it is the jaxrs out stream, (more or less servlet outputstream)

just write inside


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-20 9:55 GMT+02:00 mauro2java2011 <ma...@gmail.com>:
> i have found the page :
>
> http://java.dzone.com/articles/jax-rs-streaming-response
>
>
> into the @Override of method write(OutupStream out){
>
> }
>
> it is used the object out but i not understand do  it came from .
>
> in the example it  not is referencued  externally  any method
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668913.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by mauro2java2011 <ma...@gmail.com>.
i have found the page : 

http://java.dzone.com/articles/jax-rs-streaming-response


into the @Override of method write(OutupStream out){

}

it is used the object out but i not understand do  it came from .

in the example it  not is referencued  externally  any method




--
View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668913.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
more or less

return new StreamingOutput() {

    @Override
    public void write(OutputStream os) throws ... {
      os.write(bInput);
    }
  };

Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-10 11:09 GMT+02:00 mauro2java2011 <ma...@gmail.com>:
>  byte[] by= photo.getImmagine();
>
> ByteArrayOutputStream bInput = new ByteArrayOutputStream(by);
>
>
>
> Response. //  WHAT WRITE AFTER Response ?
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668699.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by mauro2java2011 <ma...@gmail.com>.
 byte[] by= photo.getImmagine();

ByteArrayOutputStream bInput = new ByteArrayOutputStream(by);



Response. //  WHAT WRITE AFTER Response ?




--
View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668699.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
did you check ByteArrayOutputStream?
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-10 10:41 GMT+02:00 mauro2java2011 <ma...@gmail.com>:
> Supoose  i have a ejb named DAO and a entity named Photo.
> The Photo contains a properties bytes[] immagine .
> the  entyty is persisted with jpa into db.
> so into my class for rest i can :
> @Inject DAO dao;
> Photo photo= dao.getPhoto(Long id);
> byte by=photo.getImmagine();
>
> and how is it  the code for output stream ???
>
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668696.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by mauro2java2011 <ma...@gmail.com>.
Supoose  i have a ejb named DAO and a entity named Photo. 
The Photo contains a properties bytes[] immagine .
the  entyty is persisted with jpa into db.
so into my class for rest i can :
@Inject DAO dao;
Photo photo= dao.getPhoto(Long id);
byte by=photo.getImmagine();

and how is it  the code for output stream ???






--
View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668696.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by mauro2java2011 <ma...@gmail.com>.
Ok but into method write (OutputStream output)  i have to pass a
ByteArrayOutputStream if i get a byte[] for example from a entity jpa saved
into db ?

And if i get the image from a file saved into a dir on server i have to pass
a FileOutputStream? 







--
View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691p4668694.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: how stream a image from a web service apache cxf ?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

personally I use
https://jsr311.java.net/nonav/javadoc/javax/ws/rs/core/StreamingOutput.html
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-10 10:00 GMT+02:00 mauro2java2011 <ma...@gmail.com>:
>
> http://
> http://www.javatips.net/blog/2013/06/download-image-file-using-cxf-rest-jax-rs
> <http://
> http://www.javatips.net/blog/2013/06/download-image-file-using-cxf-rest-jax-rs>
>
>
> The above tutorial show how download a file image from webservice apache
> rest cxf.
>
> but it permit to make save file on device client like saveAs .
>
> i would know how get a image for visualise it into a web page with using the
> call at webservice .
>
> I think that i have to stream the image and not set the content- disposition
> from the method into web service?
>
> Do you have a link for ot or suggestions...?
>
>
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/how-stream-a-image-from-a-web-service-apache-cxf-tp4668691.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.