Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 717

Read an image file using okhttp3.RequestBody in java and send it to client using HTTPServletResponse

$
0
0

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.


Viewing all articles
Browse latest Browse all 717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>