Save File
Audience:
Low-code EngineersSkill Prerequisites:
Tokens,HTTP basics
Saves a file to a portal folder. The file's contents can come from three sources:
- Url: the file is downloaded from a URL with an HTTP
GETrequest. - Text: the text you provide, which can contain tokens, is saved as the file.
- Base64: a Base64 string in Data URI format (for example
data:image/png;base64,iVBOR...) is decoded and saved.
Details of the saved file, such as its URL and file ID, can be saved as tokens for use by the actions that follow.
Older documentation called this action Save file to disk, its Content Source parameter Input mode, and its Base64 option Base64 image. The Base64 option accepts any file type, not just images.
Typical Use Cases
- Download a file from an external API or web address and store it on the site
- Save a signature or drawing captured in the browser as a Base64 image
- Write generated text such as CSV, JSON, XML or HTML to a file
- Save the output of a report service before emailing it or uploading it with Upload to FTP
Don't use it to
- Save files that users upload through a form. Single File Upload and Multi File Upload fields save uploads for you.
- Download from URLs that need a method other than
GET, or a request body. Use Server Request to call the service, then save the result with the Text or Base64 content source. - Create PDF, Word or Excel documents. Use Generate PDF, Convert from HTML to Word or Create Excel from List.
Related Actions
| Action Name | Description |
|---|---|
| Server Request | Calls an HTTP endpoint with any method, headers and body. |
| Get or Create Folder | Creates the destination folder and returns its path as a token. |
| Unpack an archive | Extracts a downloaded archive. |
| Upload to FTP | Uploads the saved file to an FTP server. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Content Source | Where the file's contents come from: Url, Text or Base64. | No | Url | Yes |
| Url | Url only. The address of the file to download. A GET request is sent to this URL. | Yes | empty string | Yes |
| Headers | Url only. Extra HTTP headers to send with the request, as name and value pairs, for example Authorization = Bearer [ApiToken]. Both names and values support tokens. | Yes | empty | No |
| Content | Text and Base64 only. For Text, the contents of the file. For Base64, a Data URI string such as data:application/pdf;base64,JVBERi0x.... | Yes | empty string | Yes |
| Folder | The portal folder to save the file in. Select a folder, or in expression mode enter a folder path relative to the portal root, or a folder ID. When a path is given, missing folders are created. | Yes | none selected | Yes |
| Filename Pattern | The name for the saved file, for example [User:Username]-signature. How the extension is chosen depends on the content source. See How the file name is chosen. Leave empty to use a name from the server's response or a random name. | Yes | empty string | No |
| Allowed Extensions | Url and Base64 only. A list of allowed file types, chosen from the site's MIME types. If the downloaded or decoded file's type isn't in the list, the action fails and nothing is saved. Leave empty to allow any type. | No | empty | No |
| Handle Duplicates | What happens if a file with the same name already exists in the folder. Rename saves the new file with a unique suffix added to its name. Overwrite replaces the existing file. | No | Rename | Yes |
Output Parameters Reference
Each output is optional. Enter a token name in the ones you need.
| Parameter | Description |
|---|---|
| Absolute URL Output Token Name | Token that receives the file's absolute URL, for example https://example.com/Portals/0/Signatures/jdoe-signature.png. |
| Relative URL Output Token Name | Token that receives the file's URL relative to the site root, for example /Portals/0/Signatures/jdoe-signature.png. |
| Physical Path Output Token Name | Token that receives the file's physical path on the server. |
| Link Click Output Token Name | Token that receives a LinkClick URL that downloads the file. |
| File Id Output Token Name | Token that receives the file ID. |
How the file name is chosen
| Content Source | Name | Extension |
|---|---|---|
| Text | Filename Pattern, or a random name if empty. | The extension in Filename Pattern. If there isn't one, .txt is used. |
| Url | Filename Pattern, or else the file name in the response's Content-Disposition header, or else a random name. | Taken from the response's Content-Type header. If there's no Content-Type, taken from the Content-Disposition file name, then from the URL, and finally .txt. An extension in Filename Pattern is ignored. |
| Base64 | Filename Pattern, or a random name if empty. | Always taken from the MIME type in the Data URI. An extension in Filename Pattern that doesn't match is replaced. |
Considerations
- Failed downloads. If the URL returns an HTTP error status, for example
404or500, the action fails and the status is written to the site's event log. - Allowed file extensions. The file's extension must be in the site's list of allowed file extensions, otherwise saving fails.
- Text encoding. Text content is saved as UTF-8.
- Security. Only download from URLs you trust, and don't save untrusted content into public folders. Use
Allowed Extensionsto block unexpected file types.
Examples
To understand how to use the below examples, please see Running Examples.
1. Download a file from an API that needs a bearer token
This action downloads an invoice PDF from an external API, sends an Authorization header, allows only PDF files, and saves the file as Invoices/INV-<InvoiceNumber>.pdf. The file ID is saved in the InvoiceFileId token.
{
"Title": "Save File",
"ActionType": "SaveFileToDisk",
"Description": "Download the invoice PDF",
"Condition": null,
"Parameters": {
"InputMode": {
"Expression": "",
"Value": "Url",
"IsExpression": false,
"Parameters": {}
},
"Url": "https://api.example.com/invoices/[InvoiceNumber]/pdf",
"Headers": {
"Authorization": "Bearer [ApiToken]"
},
"Content": "",
"Folder": {
"Expression": "Invoices",
"Value": "",
"IsExpression": true,
"Parameters": {}
},
"Pattern": "INV-[InvoiceNumber]",
"AllowedExtensions": [
{
"MimeType": ".pdf"
}
],
"Duplicates": {
"Expression": "",
"Value": "Overwrite",
"IsExpression": false,
"Parameters": {}
},
"AbsoluteURLOutputTokenName": "",
"RelativeURLOutputTokenName": "",
"PhysicalPathOutputTokenName": "",
"LinkClickOutputTokenName": "",
"FileIdOutputTokenName": "InvoiceFileId"
}
}
2. Save a CSV file from text
This action writes a small CSV file built from tokens to Exports/contact-<Id>.csv and saves its absolute URL in the CsvUrl token.
{
"Title": "Save File",
"ActionType": "SaveFileToDisk",
"Description": "Write a CSV file",
"Condition": null,
"Parameters": {
"InputMode": {
"Expression": "",
"Value": "Text",
"IsExpression": false,
"Parameters": {}
},
"Url": "",
"Content": "Name,Email\n[FirstName] [LastName],[Email]",
"Folder": {
"Expression": "Exports",
"Value": "",
"IsExpression": true,
"Parameters": {}
},
"Pattern": "contact-[Id].csv",
"Duplicates": {
"Expression": "",
"Value": "Rename",
"IsExpression": false,
"Parameters": {}
},
"AbsoluteURLOutputTokenName": "CsvUrl",
"RelativeURLOutputTokenName": "",
"PhysicalPathOutputTokenName": "",
"LinkClickOutputTokenName": "",
"FileIdOutputTokenName": ""
}
}
3. Save a signature captured as a Base64 image
This action saves the Base64 PNG in the Signature field as Signatures/<Username>-signature.png. The extension comes from the Data URI.
{
"Title": "Save File",
"ActionType": "SaveFileToDisk",
"Description": "Save the signature image",
"Condition": null,
"Parameters": {
"InputMode": {
"Expression": "",
"Value": "Base64",
"IsExpression": false,
"Parameters": {}
},
"Url": "",
"Content": "[Signature]",
"Folder": {
"Expression": "Signatures",
"Value": "",
"IsExpression": true,
"Parameters": {}
},
"Pattern": "[User:Username]-signature",
"Duplicates": {
"Expression": "",
"Value": "Overwrite",
"IsExpression": false,
"Parameters": {}
},
"AbsoluteURLOutputTokenName": "",
"RelativeURLOutputTokenName": "SignatureUrl",
"PhysicalPathOutputTokenName": "",
"LinkClickOutputTokenName": "",
"FileIdOutputTokenName": ""
}
}
Revised 09/25/2026