
1 Antwort
Hi Abanoub,First query the custom object and get the image url. Now, do an HTTP GET to retrieve the image and then assign it to FeedItem insertion.To get the blob data from an image urlHttp h = new Http();HttpRequest req = new HttpRequest();string firstImageURL = 'http://www.samplesite.com/testimage.jpg';firstImageURL = firstImageURL.replace(' ', '%20');req.setEndpoint(firstImageURL);req.setMethod('GET');req.setHeader('Content-Type', 'image/jpeg');req.setCompressed(true);req.setTimeout(60000); HttpResponse res = null;res = h.send(req);string responseValue = '';responseValue = res.getBody();system.debug('Response Body for File: ' + responseValue);blob image = res.getBodyAsBlob();// Prepare the FeedItem with the image blob for insertionFeedItem post = new FeedItem();post.ParentId = u.id;post.CreatedById='005E0000003XWRs';post.Body ='Hello '+u.name;post.ContentData = image;post.ContentFileName = 'sample.png';insert post;Please let me know if this helpsBest RegardsNaga kiran