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]