File handling
Jigx stores files as local files on the device and only saves the file URI to the file in the datastore/state. When a component needs the binary data, it can read the local file from the file URI. To enable the handling of files, you can convert files from base64, data-uri, or buffer to local-uri.
Type of files:
- Images
- Documents
Image files can be used in the following functionality:
- REST Provider calls with files
- SQL Provider calls with files
- Datasource queries with files
- Actions with files
A new property has been added called conversions.
Core structure | |
conversions: | This holds an array of properties that should be converted. Three properties control the conversion: property: The name of the property to convert. from: Format of the input data. Can be buffer, base64, data-uri, or local-uri. to: Format of the converted data. Can be base64, data-uri, buffer or local-uri. |
Referencing files in a - You can access the blob, base64, data-uri value using the state of the components and properties in a , such as media-field or avatar-field. When referencing files in s uses the .state.value configuration. For example:
- file: [email protected]
- image: [email protected]
- Conversions should be done within the function if available. When the conversion is done in the function, it stores the data as the 'from' type in the datasource.
- When conversions are done at the datasource level, they are still stored in the datasource as their original value. They are only converted after the fact when requested; however, the datasource value does not change.
- Do not load data back from buffer using the Dynamic Data provider, the file will not show.
- When saving images to consider the file size. You can reduce the file size in the media-field by configuring the imageQuality property.
In this example, the file conversion is configured in the SQL function to convert the incoming files.
In this example, the file conversion is configured in the SQL function to convert the files that are outgoing to SQL.
In this example, the file conversion is configured in the REST function to convert the incoming files.
In this example, the file conversion is configured in the REST function to convert the files that are outgoing via REST.
In this example, the file conversion is configured in the datasource to convert the files to be used in the solution.
File conversions in actions can be used with Dynamic Data, SQL and REST provider.
This example uses the text-field with mediaType: image and isMultiple: true to add multiple iamges to SQL. The conversion of the files is done in the SQL function.