Get File Data – reading the content of a stored file¶
The command "Get File Data" reads the content of a stored file into a variable, base64 encoded. This page is for administrators who pass files on – as a mail attachment, in an API call, or to a command that reads the file line by line.
1. At a glance¶
| Purpose | Read a file from a file storage into a variable |
| Typical use | Attach a stored file to a mail; send a file to another system; import a stored CSV or Excel file |
| Where in the editor | Toolbar menu "Files" → "Get File Data" |
| Needs a user interface | No |
| Needs a current record | No |
| Related | Get Files, Iterate File Lines, Send E-Mail |
2. Settings¶
The settings are on the tab "Settings". "Display Name", "Description" and "Execution Condition" are on the tab "General" (see Actions).
| Setting | Meaning | Default / Required |
|---|---|---|
| "File Provider" | The kind of storage: "Azure Blob Storage" or "S3 Storage" | Required |
| "Credentials" | The credentials of the storage, of the kind that matches the file provider | Required |
| "File Id" | Expression for the ID of the file – for example the Id of an entry of the list that Get Files writes |
Required |
| "Result Variable" | The variable the content is written into, base64 encoded | Required |
3. Behaviour¶
- Without "File Provider" or "Credentials", or with an empty "File Id", the command is skipped.
- The file is read from the storage and written into "Result Variable" as base64 text.
- If the file does not exist or cannot be read, the reason is written to the log, the variable keeps its previous value and the action continues. Check the variable before you use it.
The command reads from the storage. A file that Add File has queued but that has not been saved yet cannot be read.
The whole file is held in memory as text. Very large files make the action slow and use a lot of memory on the server.
4. Examples¶
Import a CSV file that a user uploaded into a files form block.
- Get Files with the identifier of the files block writes the list into
UploadedFiles. - "Get File Data" with "File Id" = the
Idof the first element ofUploadedFiles, "Result Variable"FileContent. - Iterate File Lines with "File Path or Content"
FileContent, "Is File Content" and "Is Base64" on, "Data Type"CSV.
Send a stored file to another system. Use the variable as body (or part of a JSON body) of an HTTP Request if the other system accepts base64 content.
5. Limitations¶
- No error variable: a failed read is only visible in the log and in a variable that did not change.
- The content is always base64. Use a Modify Value expression with the rule
DecodeBase64to get text.