Requirement : Get Image Using Http Request To Image url
Here in this post we will get the image by the help of image url using http request.
So we send a http request to the image url and get response body as blob later we convert blob into apex image or you can directly use blob to shoe image in your html or visualforce page by using html image tag
Steps to be followed :
- Send Http request to image url and get image as a blob from response body
- display image on html page using Html image tab
Step 1 : Sending http request
HttpRequest imgreq = new HttpRequest();
imgreq.setmethod(‘GET’);
imgreq.setEndpoint(ld.Image_Url__c);
Http binding = new Http();
HttpResponse imgres = binding.send(imgreq);
// converting response as a blob
Blob imageblob = imgres.getBodyAsBlob();
image = EncodingUtil.Base64Encode(imageblob);
Step 1 : Display image on html using img tag
<img src="data:image/png;base64,'.base64_encode('your blob variable').'"/>
Hits: 1578
I’m now not sure where you’re getting your info, however great topic.
I must spend a while learning more or understanding more.
Thanks for magnificent info I was in search of
this information for my mission.