Need assistance with displaying AWS S3 image(base64 encoded) in section rule -

Hi there,

We have come across a requirement in our application that requires the Pega platform to retrieve an image from an AWS S3 bucket and display it under the data class."

Approach:

  • Created a new repository (Data-Repository) instance with AWS S3 storage.
  • Leveraged the OOTB data page (D_pxGetFile) to retrieve the image using the repository and file path.
  • Received the content in base64 encoded format.
  • Created a section rule in the data class with the following code:
Decoded Image
<script>

            var base64String = "<%= tools.getHTMLValue('PropertyName') %>";

            document.getElementById('decodebase64Image').src = "data:image/jpeg;base64," + base64String;

        </script>

    </body>

</html>
  • Rendered the section rule on the parent section.

Unfortunately, the approach did not work. Appreciate it if any insights can be shared.

Cheers,

Narendra Potnuru

@NPOTNURU - You can try the below

Decoded Image

The propertyName should contain the whole string “data:image/png;base64,” + the base64 value.

@KALINGAROUT Thanks for the solution. The recommended approach worked.