Reputation: 410
I'm new with API REST and I have one question/problem.
Currently I have an API REST (FosRestBundle) with Symfony (2.8.1) and all is OK, I have a json response with an array with some data...one of this field is a image (in my backend I used VichUploaderBundle).
How I can do to send the image in json? I need to serialize the image? base64? JMSSerializer?
This is the correct way? Serialize the image and later, in the other client deserialize?
Thanks!!
Roger
Upvotes: 0
Views: 650
Reputation: 17936
the correct way is to just serve the link to the ressource
like:
[
{
bla: "blubb",
img: "http://blubb.com/blubb.jpg"
},
{
bla: "blubb1",
img: "http://blubb.com/blubb1.jpg"
},
{
bla: "blubb2",
img: "http://blubb.com/blubb2.jpg"
}
]
and whatever then uses this data will call the URI to display the image
Upvotes: 1