I am new here and I want first to ask excuses if I don't get to express very well myself or for my English!!
In fact, I'm working on a project that is supposed to get byte array from a Firebird database and represent them on android. So I decided to use a restful webservice with a methode that get these daten from database and then use android client to retrieve them.
How can I please write these bytes in a text file and then get this using an android client!
The methode on web service looks like this:
@GET
@Path("daten/{id}")
@Produces("text/plain")
*// Instead of byte[] I wanted to return a file because this doesn't work*
public byte[] getDaten(@PathParam("id") String id){
Tbpatereignis res= (Tbpatereignis) em.createQuery("select erg from Tbpatereignis as erg where erg.vcereignis= :ekgtyp and erg.vcpatsur.vcsurrogat= :id ").setParameter("ekgtyp", "UREKG").setParameter("id", id).getResultList().get(0);
return res.getBldivers();
}
How can I then retreive this file from a restful web service and use it later on android?
Thanks for ur help!
you should use @Produces("application/octet-stream") not @Produces("text/plain"). In android client you can use httpclient or URLConnection to issue http request.
example code for URLConnection to get image from server:
URL url = new URL(urlStr);
URLConnection connection = url.openConnection();
Bitmap bmp=BitmapFactory.decodeStream(connection.getInputStream());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With