Download a file
Download a file in jig
This example displays a department's expenses in a list. The expense receipt is downloaded by tapping the button to the right of the expense. A jig opens, displaying the receipt and its metadata. To download the receipt to a localPath, the execute-entity's download method is configured. A go-to action opens a jig that displays the downloaded file in an image component and the file's metadata in entity-fields.

title: Department Expense list
description: List of Expenses
type: jig.list
inputs:
expenseId:
type: string
header:
type: component.jig-header
options:
height: medium
children:
type: component.image
options:
source:
uri: https://cdn.pixabay.com/photo/2023/08/22/11/57/finance-8206242_1280.jpg
# The datasource allows you to use the thumbnail image URI from the server,
# for faster loading and lower bandwidth.
# The full image for high-resolution, detailed viewing or editing.
# The image is stored in the cache (localPath) to cater for offline use,
# and repeated requests for the same image.
datasources:
expenses-ds:
type: datasource.sqlite
options:
provider: DATA_PROVIDER_DYNAMIC
entities:
- default/expenses
query: |
SELECT
id,
'$.expenseitem',
json_extract(file, '$.localPath') as localPath,
json_extract(file, '$.fileName') as filename,
json_extract(file, '$.status') as status,
json_extract(file, '$.thumbnail.base64') as thumbnail
FROM [default/expenses]
ORDER BY '$.expenseitem'
data: [email protected]
item:
type: component.list-item
options:
title: [email protected]
subtitle: [email protected]
tags:
- text: [email protected]
color: color14
leftElement:
element: avatar
text: ""
uri: |
[email protected] != null ? 'data:image/png;base64,' & @ctx.current.item.thumbnail :
@ctx.current.item.localPath != null ? @ctx.current.item.localPath
rightElement:
element: button
title: View receipt
onPress:
type: action.action-list
options:
isSequential: true
actions:
# Configure the download method to download the file,
# to a local cache, use the current item's id.
- type: action.execute-entity
options:
provider: DATA_PROVIDER_DYNAMIC
entity: default/expenses
method: download
data:
id: [email protected]
# Configure a go-to action to view the file and file metadata.
- type: action.go-to
options:
linkTo: expense-receipt-details
inputs:
expenseId: [email protected]
actions:
- children:
- type: action.go-to
options:
title: Create Expense
linkTo: files-create-expenseDownloading multiple files
In scenarios where multiple files must be downloaded, use the execute-entities action. In the data property, configure an expression using the $map JSONATA Path Operators to handle multiple entries.
Download a file in Jigx Management
Files can be uploaded in Management by following these steps:
Log in to https://manage.jigx.com.
Browse to the required solution's data tab and select the record containing the file to be downloaded.
Select the File tab in the Edit record pane.
To download the file use the Download file link at the top of the record.
Last updated
Was this helpful?