Created
February 12, 2024 15:18
-
-
Save svierk/5b75ff9f60ca15b00010a97a420f5fdc to your computer and use it in GitHub Desktop.
Apex Controller class for updating the user's profile picture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class UserProfilePictureController { | |
@AuraEnabled | |
public static void updateProfilePicture(String base64) { | |
try { | |
Blob b = EncodingUtil.base64Decode(base64); | |
ConnectApi.BinaryInput binaryInput = new ConnectApi.BinaryInput(b, 'image/png', 'UserPhoto.png'); | |
ConnectApi.UserProfiles.setPhoto(null, 'me', binaryInput); | |
} catch (Exception e) { | |
System.debug('The following exception has occurred: ' + e.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment