I tried to below code to send the response as byteStream, but I cannot read the image in my client side using Javascript.
Code to get image file:
Request getResponse = new Request.Builder()
.URL("/getImage")
.method("GET", null)
.addHeader("Authorization", "oauthtoken " + accessToken).build();
Response response = client.newCall(getResponse).execute();
ResponseBody rBody = response.body().bytes();
I set the byteStream rBody to a jsonObject and send it to client using HTTPServletResponse like below.
{"file" : "����\u0000\u0010JFIF\u0000\u0001\u00..."};
But I cannot read the image file from the client side.