AnsweredAssumed Answered

How to upload user avatar images to Alfresco Share?

Question asked by ofnavarro on Sep 1, 2014
Latest reply on Sep 3, 2014 by ofnavarro
Hi,

we are using the RESTFul Api Function "/alfresco/service/slingshot/profile/uploadavatar" to upload user profile images but they are not shown in Alfresco share.

How can we make to create the thumbnail like does the user account edit screen in Alfresco Share?

This is the code used for that:


File file = new File("c:/Prueba.png");

urlResourceAlfresco = "http://" + alfrescoServer + ":" + alfrescoPort + "/alfresco/service/slingshot/profile/uploadavatar";
log.debug("Url Alfresco resource: " + urlResourceAlfresco);
         
FormDataMultiPart form = new FormDataMultiPart();
form.field("username", userName);
form.field("filename", "Prueba.png");
form.bodyPart(new FileDataBodyPart("filedata", file, MediaType.MULTIPART_FORM_DATA_TYPE));
webResource = client.resource(urlResourceAlfresco);
ClientResponse responseAvatar = webResource.type(MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);


It´s working fine uploading the image and updating the user account data but the urls that appears in the property "avatar" links to an avatar thumbnail that it is no automatically created with the "uploadavatar" function.


{
   "url": "\/alfresco\/service\/api\/person\/aaa1",
   "userName": "aaa1",
   "enabled": true,
   "avatar": "api\/node\/workspace\/SpacesStore\/8d3ea206-5bf6-43e8-89be-9ecf9d026f8b\/content\/thumbnails\/avatar",
   "firstName": "Nombre pruebas1",
   "lastName": "Apellidos Pruebas 1",
   "jobtitle": "Puesto de trabajo",…
}


In Alfresco Explorer, user image avatar is correctly showed in details user screen.

Outcomes