Skip to content

Instantly share code, notes, and snippets.

@svierk
Created February 12, 2024 15:18
Show Gist options
  • Save svierk/5b75ff9f60ca15b00010a97a420f5fdc to your computer and use it in GitHub Desktop.
Save svierk/5b75ff9f60ca15b00010a97a420f5fdc to your computer and use it in GitHub Desktop.
Apex Controller class for updating the user's profile picture
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