You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Sonam Samdupkhangsar <So...@imail.org> on 2015/02/25 00:00:02 UTC

returning a object's byte array

Hi,

I have a Java Object:

class MyFile {
  Long id;
byte[] myBytes;

}

I have a JAXRS service that returns MyFile objects:

@GET
@Produces ( "application/json" )
@Path("/new")
public Set<MyFile> getMyFiles();


On the Javascript-client side, the contents of MyFile.myBytes is encoded in Base64 (not sure but looks like it).    The myBytes is a byte array containing a PDF file.  I used the "atob()" javascript method to get the binary (blob) data but I am not able to display the pdf file using the HTML's "<embed>" tag.
Not sure if this helps but I see this error on Firefox console : "Error: Invalid XRef stream header".

Thanks

-Sonam



Re: returning a object's byte array

Posted by Sergey Beryozkin <sb...@gmail.com>.
Perhaps this can help:

http://stackoverflow.com/questions/20706783/put-byte-array-to-json-and-vice-versa

Sergey
On 24/02/15 23:00, Sonam Samdupkhangsar wrote:
> Hi,
>
> I have a Java Object:
>
> class MyFile {
>    Long id;
> byte[] myBytes;
>
> }
>
> I have a JAXRS service that returns MyFile objects:
>
> @GET
> @Produces ( "application/json" )
> @Path("/new")
> public Set<MyFile> getMyFiles();
>
>
> On the Javascript-client side, the contents of MyFile.myBytes is encoded in Base64 (not sure but looks like it).    The myBytes is a byte array containing a PDF file.  I used the "atob()" javascript method to get the binary (blob) data but I am not able to display the pdf file using the HTML's "<embed>" tag.
> Not sure if this helps but I see this error on Firefox console : "Error: Invalid XRef stream header".
>
> Thanks
>
> -Sonam
>
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com