I know, that there is no way to mass-upload these images via dataloader as described here

Is there a way to access and change the image programmatically or via API? There seems to be an local app for it and I wonder on how this is done in the app: http://satrangtech.com/products.htm#4

  • Hi Uwe, Chatter Photos Bulk Importer is a JAVA based program doing mass user profile image upload. It makes REST based calls to Salesforce to upload user profile image. Let me know if you need any more details. – Chirag Mehta Jul 31 '15 at 11:43

As @jonathanwiesel mentioned, it can be done via Connect API which has an APEX wrapper and therefore it's easy and very straight forward to implement.

Here you can even find sample code for that: https://developer.salesforce.com/forums/?id=906F0000000AWe7IAG

I've checked it and it works fine for me like this:


<apex:page controller="FileUploadController">
    <apex:sectionHeader title="Visualforce Example" subtitle="File Upload Example" />

    <apex:form enctype="multipart/form-data">
        <apex:pageMessages />
        <apex:pageBlock title="Upload a File">

                <apex:commandButton action="{!upload}" value="Save" />

            <apex:pageBlockSection showHeader="false" columns="2" id="block1">

                    <apex:outputLabel value="File Name" for="fileName" />
                    <apex:inputText value="{!document.name}" id="fileName" />

                    <apex:outputLabel value="File" for="file" />
                    <apex:inputFile value="{!document.body}" filename="{!document.name}" id="file" />

                    <apex:outputLabel value="Description" for="description" />
                    <apex:inputTextarea value="{!document.description}" id="description" />

                    <apex:outputLabel value="Keywords" for="keywords" />
                    <apex:inputText value="{!document.keywords}" id="keywords" />




public without sharing class FileUploadController {

    public Document document {
        get {
            if (document == null)
                document = new Document();
            return document;

    public PageReference upload() {
        Blob b;
        document.AuthorId = UserInfo.getUserId();
        document.FolderId = UserInfo.getUserId(); // put it in running user's folder

        try {
            document.type = 'jpg';
            document.IsPublic = true;
            insert document;
            // ImageId = '06990000001HnuB';
            b = document.Body;
            //ConnectApi.ChatterUsers newPhoto = new ConnectApi.ChatterUsers();

        } catch (DMLException e) {
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'Error uploading file'));
            return null;
        } finally {
            document.body = null; // clears the viewstate
            document = new Document();

        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'File uploaded successfully : ' + b));
        String communityId = null;
        String userId = UserInfo.getUserId();
        //ID fileId = ImageId;

        // Set photo
        ConnectApi.Photo photo = ConnectApi.ChatterUsers.setPhoto(communityId, userId, new ConnectApi.BinaryInput(b, 'image/jpg', 'userImage.jpg'));
        return null;


You could use the new Connect API.

Specifically the ChatterUsers Class with the setPhoto method.

However I believe this would not work for bulk as your initial requirement states.

  • You could set up a batch method for this to do it asynchronously. – MayTheSForceBeWithYou Jun 6 '17 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.