UserAccessor.setUserProfilePicture: Need a little help with this method

scott_boisvert
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 19, 2020

So I'm trying to upload profile pictures for our Active Directory. I was able to accomplish this in Jira, but I'm having some issues with setting the picture in Confluence (getting the picture isn't a problem).

I've been trying to use the 

void setUserProfilePicture(com.atlassian.user.User targetUser,
                           String imagePath)

That is documented here: https://docs.atlassian.com/ConfluenceServer/javadoc/7.2.1/index.html?index-all.html

I'm thinking I'm having a problem with this sentence: The path should be the web-application-root-relative path to the image to be used as the user's profile picture

import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.user.UserAccessor

def userAccessor = ComponentLocator.getComponent(UserAccessor)
confUser = userAccessor.getUserByName("boisvers")
userAccessor.setUserProfilePicture(confUser, "/data/atlassian/application-data/confluence/scripts/data/Oscar.jpg")

I did notice that if I manually upload my profile picture, then run the script. The manual profile pic is removed and replaced with the silhouette avatar.

1 answer

1 accepted

0 votes
Answer accepted
scott_boisvert
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 19, 2020

Well I figured this out.... lol 
Been working on this for two days now and 35 minutes after posting I figured it out. 

Profile pics need to be under the images directory (preferable images/icons/profilepics).

Then use "/images/icons/profilepics/test.png" in the setUserProfilePicture....

userAccessor.setUserProfilePicture(confUser, "/images/icons/profilepics/test.png") 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.2.1
TAGS
AUG Leaders

Atlassian Community Events