Convert File to Base64
Verb: fileToBase64
Available from: <Standard>
Converts a file to Base64.
Base64 encoding is a process of converting binary data to an ASCII string format, converting this binary data into a 6-bit character representation.
Syntax
fileToBase64 --filepath(String) [--fileSystem(FileSystem)] (String)=value
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--filepath | File Path | Required | Text | Path of the file that should be converted. |
--fileSystem | File System | Optional | File System | Connection variable to a file system.
1. To obtain the connection variable with an available file system, this connection must be established using one of the following commands: IBM RPA Control Center. 2. If nothing is specified in this parameter, the local file system of the operating system is used as default. |
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
value | Base64 | Text | Returns the file converted to Base64 format. |
Example
The Convert File to Base64 command converts the text file named "txtRPA" to Base64.
defVar --name base64File --type String
// Download the following file to execute the command.
fileToBase64 --filepath "txtRPA.txt" base64File=value
logMessage --message "${base64File}" --type "Info"
// Results in base64 content:
//BBIG91IFJvYm90aWMgUHJvY2VzcyBBdXRvbWF0aW9uIOkgdW1hIHRlY25vbG9naWEgcXVlIGVuZ2xvYmEgbyB1c28gZGUgcm9i9HMgaW50ZWxpZ2VudGVzIGVtIHF1YWxxdWVyIHByb2Nlc3NvIHF1ZSBuZWNlc3NpdGUgZWZpY2nqbmNpYSwgY29uc2lzdOpuY2lhLCB2ZWxvY2lkYWRlIGUgZWxpbWluZSBvIHJpc2NvIGRlIGVycm9zLiA=
For the correct operation of the script above, it is necessary to download the file and insert its path in the Path parameter of the Convert File to Base64 command.