When implementing a scripted customization, support for end-users uploading files is often required. Files can be specified in script configuration or through a UI rendered by a script.
[toc]
Files Uploaded through Configuration
All scripted customizations support exposing configuration options using dynamic configuration. Dynamic configuration supports embedding files in configuration properties of the following types:
- HTML. HTML properties can support uploading files through the HTML editor. Uploaded files are stored with the configuration.
- URL. URL properties can optionally support uploading files to be stored with the configuration.
- URLList. URL list properties can optionally support uploading multiple files to a single configuration property value to be stored with the configuration.
- Custom. Custom properties can include configuration metadata to allow Verint Community to detect CFS-stored files referenced within the custom value. When configured, Verint Community will detect and store those files with the configuration.
See Using Dynamic Configuration and the default property templates for more details about each of these data types and their file-related configuration options.
As an example, consider the following dynamic configuration XML:
<propertyGroup id="options" labelText="Options"> <property id="file" labelText="File" dataType="url" allowLocal="true" allowRemote="false" enablePreview="true" allowedFileExtensions="jpg,jpeg,gif,png,svg" /> </propertyGroup>
This defines a single property named "file" of type url
. Using the default rendering for url properties, url, it defines a few template-specific configuration options:
- allowLocal. Setting this to true enables files to be uploaded to this property.
- allowRemote. Setting this to false disables manually entering a URL for this field--causing it to be upload-only.
- enablePreview. Setting this to true enables a preview of the selected file.
- allowedFileExtensions. This can be set to a comma-separated list of file extensions that are allowed to be selected for this property.
When presented to end users, this property is rendered as:
The "Upload" link opens a file selection UI (provided by the web browser). When a file is selected, it's name is shown along with a preview:
The file can then be changed (uploading a new file) or removed (setting the property back to empty/null).
Within a script, the URL of the selected image is retrieved from core_v2_widget.GetUrlValue()
and can be used with core_v2_ui.GetResizedImageHtml()
(since this is an image file) using the script
$core_v2_ui.GetResizedImageHtml($core_v2_widget.GetUrlValue('file', ''), 300, 300, "%{ ResizeMethod = 'ZoomAndCrop' }")
to resize and render the file as