July 5, 2022

Samir Daoudi's Technical Blog

SharePoint, Office 365, C#, .Net, SQL Server News, Tips, Ebooks, Events, Webinars ….etc

Power Apps – Convert User profile picture to Base64

Today, I will explain how we can convert a picture to a base64 string.

The context for this request is a project in which I allow users to update their profile pictures with a badge showing their skills.

However, as I wanted to provide the users with the capability of restoring back their previous picture in case they dont like the new badge, I had to save the user profile picture in a location where it can be easily retrievable. I’ve opted for a SharePoint list, and created a multi line text field to store the base64 value of the user’s profile picture.

 

For this demo, I have created:

  • A Canvas app (phone layout).
  • I added into this app the following controls:
    • Label : to display the user full name
    • Image : for the user profile picture
    • Button : to generate the base64 value of the user profile picture, this value is stored in a temporary variable
    • Textbox : to show the variable

The button action is a simple as :

onSelect –>

Set(varBase64,JSON(User().Image,JSONFormat.IncludeBinaryData))

Once I set the varBase64 variable, I can set the TextBox value to this variable

The result will look like this:

Leave a comment

You may have missed

Show Buttons
Hide Buttons

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

%d bloggers like this: