How to convert text file to base64 string in UiPath
Sometimes we need to convert a text file to base64 so that we can pass that value somewhere and use it there.
In this article, let’s see how we can achieve this task:
Step1: First we need to read the text file and store it in an array of bytes. Drag and Drop an assign activity from the activities panel to the designer panel and enter the code as shown below:
Here:
bytes is a variable of type array of bytes.
Step2: Now we need to convert the array of bytes into a base64 string. Drag and Drop an assign activity from the activities panel to the designer panel and enter the code as shown below:
Here:
jsonbase64 is a variable of type string.
Step3: The output of the code designed above is shown below:
eyJuYW1lIjoiSm9obiIsICJhZ2UiOjMwLCAiY2FyIjpudWxsfQ==
This is how we can convert text file to base64 string using UiPath.
Thx!