Uploading group avatars programmatically

Hi

I am trying to upload some group avatars and have changed the code to use AvatarFileUploadContext and AvatarFileName as the AvatarFileData element is now flagged as depreciated 

so for example 

using (Stream stream = groupIcon.OpenReadStream())
{
	var uploadContext = Apis.Get<IUploadedFiles>().CreateContextId();

	var tempFile = Apis.Get<IUploadedFiles>().AddUpdate(uploadContext, groupIcon.FileName, stream);
	if (tempFile != null)
	{
		var success = Apis.Get<IGroups>().Update(existingGroup.Id.Value, new GroupsUpdateOptions()
		{
			AvatarFileName = tempFile.FileName,
			AvatarFileUploadContext = uploadContext
		});
	}
}


The file gets uploaded into the multi file upload as expected, but the group avatar ends up with an additional suffix so for example 

xxxxxxxxxxxxx/.../local.svg.svg

Actually this also seems to happen when creating/updating the group avatar via AvatarFileData  as well




Added extra info
[edited by: Karl Barber at 3:37 PM (GMT 0) on Mon, Nov 15 2021]
Parents
  • Hi . This renaming is an unfortunate side effect of the somewhat legacy support for group avatars to be resized on upload instead of just on render as with other media according to the group avatar max width/height configuration. It happens through the UI too when managing groups. It's potentially worth noting that this shouldn't affect the rendering of the group avatars in the UI.

    I've logged the following for review to ideally maintain the existing file name if the extension is not being otherwise adjusted by the platform. 

    TE-17243

    Thanks for bringing this forward!

Reply
  • Hi . This renaming is an unfortunate side effect of the somewhat legacy support for group avatars to be resized on upload instead of just on render as with other media according to the group avatar max width/height configuration. It happens through the UI too when managing groups. It's potentially worth noting that this shouldn't affect the rendering of the group avatars in the UI.

    I've logged the following for review to ideally maintain the existing file name if the extension is not being otherwise adjusted by the platform. 

    TE-17243

    Thanks for bringing this forward!

Children
No Data