You need to sign in to do that
Don't have an account?
Rajendra Rathore
Add Remote Site Setting Url At Runtime Using Apex Code and Change Profile Photo Of User From Profile Photo Url
I'm trying to change User Profile Photo from a Profile Photo url.
So to get a image body from image url i'm make a http request on that url like:
HttpRequest req= new HttpRequest();
req.setEndPoint(currentUser.Profile_Photo_Url__c);
req.setMethod('GET');
Http http = new Http();
HttpResponse res = new HttpResponse();
res = http.send(req);
ConnectApi.ChatterUsers.setPhoto(null, currentUser.id, new ConnectApi.BinaryInput(res.getBodyAsBlob(), 'image/jpg', UserInfo.getLastName()+'.jpg'));
But the Profile Picture url may be from Facebook,Yahoo,Google+, Linkedin etc and before make a http request that End Point url required in Remote Site Setting.
Can anyone please let me know how can i set endpoint url in remote site setting at runtime using apex code.
Also is there any other way to download image from url and change User profile photo from Url?
Thanks
So to get a image body from image url i'm make a http request on that url like:
HttpRequest req= new HttpRequest();
req.setEndPoint(currentUser.Profile_Photo_Url__c);
req.setMethod('GET');
Http http = new Http();
HttpResponse res = new HttpResponse();
res = http.send(req);
ConnectApi.ChatterUsers.setPhoto(null, currentUser.id, new ConnectApi.BinaryInput(res.getBodyAsBlob(), 'image/jpg', UserInfo.getLastName()+'.jpg'));
But the Profile Picture url may be from Facebook,Yahoo,Google+, Linkedin etc and before make a http request that End Point url required in Remote Site Setting.
Can anyone please let me know how can i set endpoint url in remote site setting at runtime using apex code.
Also is there any other way to download image from url and change User profile photo from Url?
Thanks
Hope you will be able to solve your problem with this workaround.
Please mark it as best solution to your problem if it does solve your problem.
@Deepak Kumar But can you please let me know how can i'm insert an attachment from a photo url without making a http request on that url?
For example: I have profile photo url: https://lh5.googleusercontent.com/-vyn06sBsZu0/AAAAAAAAAAI/AAAAAAAAAOE/13GydQhKgnA/photo.jpg?sz=400
So how can i'm save that image from url and save in attachment in salesforce?
Thanks