-1

tried reading on SO - but am not very clear.
have not yet tried any code - so have nothing to show.
My Java REST service returns JSON data with a flag indicating if an image exists with image name.
Now I want to retrieve the image using JQuery.
$1
Should I store the image in database as BLOB and return some kind of byte array ?
$2
in one of the SO posts :
"You should simply use a servlet for sending images and just send some url variable in JSON. (like ?pic_id=034enifuwbf0329 "
from here :How to send an image to a Javascript client using JSON from a Java server

how is that done - the option 2 ?

so which option is better ?
any other option that I should use ?
the client is a browser not a mobile

Community
  • 1
  • 1
eXamScripts
  • 447
  • 1
  • 4
  • 11

1 Answers1

1

If I understand your question properly:

Storing the image path in the DB rather than a long blob/data url is more much effecient in my opinion. Have a DB column named filepath or something and then when you want to display it you can output

<img src="(insert DB response filepath)">
KrakenDev
  • 186
  • 9