I'm aware of the restrictions and improvement request for allowing administrator's to change a user profile's picture (hey, Atlassian, fix that already!). In the meantime, is there some way to do this in the back-end? Perhaps through the command line interface or a plugin?
Small disclaimer: this works great on my setup. I have not tested it outside of my setup. It should work just fine as I am using the standard API's that come with Confluence, but it is an open source project and I'm not getting paid for it, so I haven't done extensive testing in all scenarios.
That said, here is a utility I created to upload user photos in batch. You can get the source here ...
The compiled binary is here...
Basically you supply the program with a folder where the user photos are. It will pull in all the .jpg,.jpeg, .tif, .tiff, .png, and .bmp files in the folder. The photos should be in this format username.png, username.jpg, etc. Since Confluence profile photos are 48x48 and most photos are not square it will do face detection and then crop the photo unless you specify otherwise(via a checkbox). It has a form mode (just click on the executable) and a headless mode (supply the command line arg /headless) for automating the process. Hope this helps you out.
OK, unfortunately I couldn't get it to work. I supplied with the correct information, photos, etc. But I get the following error:
"System.InvalidOperationException: Client found response content type of 'text/html; charset=UTF-8', but expected 'text/xml'.
The rest of error message I can't get to because of the odd way the error message is returned. Any ideas?
Hmmm ... shoot. :) Would you be able to let me see what is in the ConfluenceProfilePhotos.exe.config file ... minus the encrypted password line? Also, do you have Confluence behind a reverse proxy or are you accessing the Tomcast server directly? Lastly, what OS is the server? Oh also, do you have the "Remote API" feature turned on under Confluence Admin -> General Configuration? If you want an address to email the config file you could send it to fredclown at gmail.
OK I have used Davin's program and I can report that it is exactly what I wanted. Once the issues with the SOAP interface was resolved it worked like a charm. It uploaded them quickly and efficiently and I didn't notice any significant performance problems during the process.
#!/usr/bin/python # BulkPhotoUpload.py #Script to read *.png files from a directory and upload as profile picture for users import os import shutil import fnmatch import xmlrpclib import string import re #Function to generate files that match a given filename pattern with in a directory def get_files_in_directory(filepat,top): for path, dirlist, filelist in os.walk(top): for userphoto in fnmatch.filter(filelist,filepat): yield os.path.join(path,userphoto) #Main Function if __name__ == '__main__': #Source Directory must be specified source = 'C:\BulkPhotoUpload\UserPhotos' # From where pictures of the users are read #Destination Directory must be specified destination = 'C:\BulkPhotoUpload\Archive' # To where pictures of the users are archived after uploading #The confluence server must be specified and the XML-RPC API must be enabled in the system server = xmlrpclib.ServerProxy('http://localhost:8090/rpc/xmlrpc') try: #Must specify the UserName & the Password of the usercontext on which the operation must be performed token = server.confluence1.login('username', 'password'); #Gets all the PNG files from the directory userphotocollection = get_files_in_directory("*png",source) #Iterate the files to upload them as profile photo for users for userPhoto in userphotocollection: pictureData = xmlrpclib.Binary(open(userPhoto,'rb').read()) picName = os.path.basename(userPhoto) userName = os.path.splitext(picName) profilePictureAdded = server.confluence1.addProfilePicture(token, userName, picName, 'image/png', pictureData) if profilePictureAdded: #Move the uploaded images to the Archive directory print "Successfully added profile picture for %s" % userName shutil.move(userPhoto, destination) else: print "Failed to add profile picture for %s" % userName except xmlrpclib.Fault, err: print "Fault code: %d" % err.faultCode print "Fault string: %s" % err.faultString
More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs