Download File – handing a stored file to the user¶
The command "Download File" sends a stored file to the browser of the user as a download. This page is for administrators who build buttons such as "Download contract".
1. At a glance¶
| Purpose | Let the user download a file from a file storage |
| Typical use | A button that downloads the newest document of a record |
| Where in the editor | Toolbar menu "Files" → "Download File" |
| Needs a user interface | Yes |
| Needs a current record | No |
| Related | Get Files, Get File Data |
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 |
3. Behaviour¶
- Without a user interface – for example in a scheduled action, a business rule running in the background or a call through the REST API – the command is skipped.
- Without "File Provider" or "Credentials", or with an empty "File Id", the command is skipped as well.
- Otherwise the browser of the user receives the file. The action waits until the browser has taken it over and then continues.
What the browser does with the file – save it, ask where to save it, or open it – depends on the browser and its settings.
4. Examples¶
"Download latest invoice" button.
- Get Files with the identifier
invoice-followed by the record ID writes the list into the variableInvoices. - "Download File" with "File Id" = a Modify Value expression on
Invoiceswith the rulesJArrayLastElementandJObjectJsonPathValue(pathId).
Put an "Execution Condition" on the second command that checks whether the list has elements
(rule JArrayHasElements), so that nothing happens when there is no invoice yet.
5. Limitations¶
- Works only where a user interface is attached.
- Only files from a file storage can be downloaded. Content that the action has only in a variable must be stored with Add File first.