I am creating a REST API in JAVA using RESTlet 2.0. I want to create an API call that will return an image from the database in a similar way as Facebook is doing in its Graph API.
Basically, I will do a GET to e.g.
http://localhost:8080/myAPI/{session_id}/img/p?id=1
This will then retrieve the blob data from the DB and then return the image in such a way that the user can display it like this:
<img src="http://localhost:8080/myAPI/{session_id}/img/p?id=1">
I know that I will probably need to set the content-type in the header to Image/PNG (assuming the image is a PNG of course), but what I'm struggling with is returning the data correctly for this to work.
Any suggestions?
Thanks!