Reputation: 236
I need to display the Image based on FindById(). So through Rest Call, I am able to fetch the image from MongoDB. But I want to display that image to a user in Brower in Html.
Following is the JSON with I get from Database.
For me now the challenge is how I will render this Image to User on Browser
{
"_id" : ObjectId("59f2e116a8e60d335f4bd6bb"),
"filename" : "Chrysanthemum.jpg",
"aliases" : null,
"chunkSize" : NumberLong(261120),
"uploadDate" : ISODate("2017-10-27T07:32:38.793Z"),
"length" : NumberLong(879394),
"contentType" : null,
"md5" : "076e3caed758a1c18c91a0e9cae3368f"
}
Upvotes: 1
Views: 1203
Reputation: 1104
You can use your Base Url + FileName to reder the image in html
for example
you can pass your domain URL path where the image is hosted + image name to complete the url to the image.
like this:
<img ng-src="http://localhost:5000/api/images/{{image-name-here}}" alt=""/>
or
<img ng-src="http://myImageDomainExample/images/Chrysanthemum.jpg" alt=""/>
Upvotes: 1