File Upload
Overview
The File Upload component is a utility component that helps select files in a component. The component can select files from the Photos folder, the Drive, and choose files after capturing the image from the camera. The File Upload component contains the Attach Document option that provides the options given below in a Native Action Sheet.
- Camera: Opens the Camera widget to take a picture and upload the captured image.
- Photos: Opens the gallery to select an image.
- Drive: Opens the File Manager/ Storage of the mobile device for the user to select a file.
NOTE: The File Upload component is used inside the Mobile Banking application.
File Upload Contracts
The File Upload component contains the following methods and events to define the options in the component.
- setData Method
- getFilesData
- onWarningCallback
- onErrorCallback
- fileSelectedCallback
- fileAddedtoSegCallback
- removeFileCallback
setData Method
This method sets data to the component. The setData method invokes in the Form controller under the preShow or postShow event callback.
| Parameter | Value |
|---|---|
| Input parameter |
A JSON object with the following key-value pairs.
|
|
Sample Input |
var data={
"documentUploadTitle": "Supporting Documents (Optional):",
"attachDocsText": "Attach Documents (Optional)",
"infoData": {
"title": "Time-Weighted Return",
"description": "Return calculation eliminates the effects on growth rates created by any inflows or outflows of cash. The time-weighted return breaks up the return into separate intervals based on whether cash was added or withdrawn.",
"closeBtnText": "Close",
"closeCallback": this.closeCallbackfun,
"isModalContainer": false
},
"typeError": "Please select valid file",
"sizeError": "Please select file less than 25MB",
"maxNumberOfFilesError": "Number of files should not be more than 3",
"optionsToSet": {
"camera": true,
"photos": false,
"drive": true
},
"maxNumberOfFiles": 5,
"maxFileSize": 2,
"expectedFileFormat": [
"jpeg",
"pdf",
"docx",
"xls",
"xlsx",
"csv"
],
"onErrorCallback": this.uploadErrorCallback,
"onWarningCallback": this.onWarningCallback,
"fileSelectedCallback": this.uploadCallback1,
"fileAddedtoSegCallback": this.uploadCallback2,
"removeFileCallback": this.uploadCallback3,
"filesData": [{
"lblDocName": "FileName",
"lblFileIcon": {
"text": "fontIconValue",
"skin": "skinName"
},
"fileObject": fileObject,
"btnCloseIcon": {
"text": "\ue935",
"onClick": this.showAlertToRemove
},
"template": this.componentUtility.getDynamicTemplateName(templateConfig)
},
{
"lblDocName": "FileName",
"lblFileIcon": {
"text": "fontIconValue",
"skin": "skinName"
},
"fileObject": fileObject,
"btnCloseIcon": {
"text": "\ue935",
"onClick": this.showAlertToRemove
},
"template": this.componentUtility.getDynamicTemplateName(templateConfig)
}
]
};
this.view.fileupload.setData(data);
|
|
Return Type |
NA |
getFilesData Method
This method retrieves the data of the files that the user selects in the component.
| Parameter | Value |
|---|---|
|
Syntax |
|
| Input parameter |
NA |
|
Sample Input |
var data = this.view.fileupload.getFilesData(); |
|
Return Type |
Returns the data of the files selected in the component. |
onWarningCallback Event
This event handles any warning that occurs in the component. When this event is triggered, the component invokes the callback function set as part of context data in the setData method.
| Parameter | Value |
|---|---|
| Input parameter |
NA |
| Programmatic Name | onWarningCallback
|
|
Sample Code |
this.onWarningCallback(); |
|
Return Type |
NA |
onErrorCallback Event
This event handles any error that occurs in the component. When this event is triggered the component invokes the callback function set as part of context data in the setData method.
| Parameter | Value |
|---|---|
| Input parameter |
NA |
| Programmatic Name | onErrorCallback
|
|
Sample Code |
this.onErrorCallback(); |
|
Return Type |
NA |
fileSelectedCallback Event
This event is triggered when the user selects a file in the component. When this event is triggered, the component invokes the callback function set as part of context data in the setData method.
| Parameter | Value |
|---|---|
| Input parameter |
NA |
| Programmatic Name | fileSelectedCallback
|
|
Sample Code |
this.fileSelectedCallback(); |
|
Return Type |
NA |
fileAddedtoSegCallback Event
This event is triggered when the user adds a file to the Segment in the component. When this event is triggered, the component invokes the callback function set as part of context data in the setData method.
| Parameter | Value |
|---|---|
| Input parameter |
NA |
| Programmatic Name | fileAddedtoSegCallback
|
|
Sample Code |
this.fileAddedtoSegCallback(); |
|
Return Type |
NA |
removeFileCallback Event
This event is triggered when the user removes a file from the component. When this event is triggered, the component invokes the callback function set as part of context data in the setData method.
| Parameter | Value |
|---|---|
| Input parameter |
NA |
| Programmatic Name | removeFileCallback
|
|
Sample Code |
this.removeFileCallback(); |
|
Return Type |
NA |
In this topic