I managed to do it with two Compose steps. The first one with
substring(replace(triggerBody()['text_1'], 'data:image/jpeg;base64,', ''), 1, sub(length(replace(triggerBody()['text_1'], 'data:image/jpeg;base64,', '')), 2))
and the second one with:
base64ToBinary(outputs('Compose_2'))
and all this at the Save button (I have a collection named 'users' which has all the users info and they're showed on a Gallery):
Set(var_ImageToBase64, JSON(UploadedImage1.Image, JSONFormat.IncludeBinaryData));
If(
AddMediaButton1.Media <> Blank(),
Set(var_ImageToBase64, JSON(UploadedImage1.Image, JSONFormat.IncludeBinaryData));
Set(result1, 'UPM|ChangeUserPicture'.Run(Gallery1.Selected.id, var_ImageToBase64));
Reset(AddMediaButton1);
);
Set(
result2,
'UPM|ModifyUser'.Run(
Gallery1.Selected.id,
If(IsBlank(CompanyNameInput.Text), "-", CompanyNameInput.Text),
If(IsBlank(DepartmentInput.Text), "-", DepartmentInput.Text),
If(IsBlank(JobTitleInput.Text), "-", JobTitleInput.Text),
If(IsBlank(CityInput.Text), "-", CityInput.Text),
If(IsBlank(PostalCodeInput.Text), "-", PostalCodeInput.Text),
If(IsBlank(CountryInput.Text), "-", CountryInput.Text),
If(IsBlank(OfficeLocationInput.Text), "-", OfficeLocationInput.Text),
If(IsBlank(MobilePhoneInput.Text), "-", MobilePhoneInput.Text)
)
);
If(
(UploadedImage1.Image <> Blank() || result1.response = "204") && result2.response = "204",
Notify("User modified.", NotificationType.Success);
Patch(users, LookUp(users, id = Gallery1.Selected.id),
{
companyName: CompanyNameInput.Text,
department: DepartmentInput.Text,
jobTitle: JobTitleInput.Text,
city: CityInput.Text,
postalCode: PostalCodeInput.Text,
country: CountryInput.Text,
officeLocation: OfficeLocationInput.Text,
mobilePhone: MobilePhoneInput.Text,
UserPhoto: If(UploadedImage1.Image <> Blank(), UploadedImage1.Image, LookUp(users, id = Gallery1.Selected.id).UserPhoto)
}
);
ClearCollect(
users,
AddColumns(
'UPM|LoadUsers'.Run(),
"UserPhoto",
Office365Users.UserPhotoV2(id)
)
);
);
If(result2.response <> "204",
Notify("Error occurred while trying to modify user.", NotificationType.Error)
);
The only thing here is that just jpeg is working to change the user picture. I tried to modify the first Compose to allow png as well but it didn't work. Any way to do it for several images types?
Thanks,
Miguel