Consume byte[] in GET using resty GWT

113 views Asked by At

in my server side i have the following :

@ApiOperation(value = "myValue", tags = "{mytag}")
@GET
@Path("mypath")
@Produces("image/jpeg")
public Response getImage(@ApiParam(hidden = true) @HeaderParam("Accept-Language") String acceptLanguage,
        @ApiParam(hidden = true) @HeaderParam("accountId") Long accountId,
        @PathParam("var1Id") Long var1, @PathParam("imageId") Long documentId,
        @PathParam("var2Id") Long var2Id) throws SyncException {
    return Response.ok(ImageService.getImage(acceptLanguage, ImageId)).build();
}

Where getImage return type is byte[] .

in my client side and using resty GWT i have the following :

@GET
@Path(mypath)
@Produces("image/jpeg")
public void getImage( @PathParam("var1Id") Long var1id, @PathParam("var2Id") Long var2Id , @PathParam("imageId") Long imageId, MethodCallback<T> callback);

my question is what should i put in the MethodeCallback to be able to use the byte[] sent by the server side ?

1

There are 1 answers

0
Othman Chahboune On

The solution that worked for me was to create an class byteResponse where the byte[] array is an attribute . then this class was now the return type of getImage in the serverSide and the type inside the methodeCallback on gwt side .