The following APIs allow users in an RTC session to send and receive file(s) with each other. Using these APIs, you can initiate a file transfer, cancel a file transfer, be notified of the availability of a file for download, and receive/download a shared file.
Table of Contents
Upload File to Share
The Enx.sendFiles()
method is used to initiate a file transfer to Video Server.
Class: Enx
Method: Enx.sendFiles(isBroadcast,clientIdList)
Parameters:
isBroadcast
– Boolean. Set it to true to share file(s) with all the participants in the Session and false to share file(s) with the intended user(s).clientIdList
– List of Client IDs intended to receive the file(s). This parameter is not applicable ifisBroadcast
parameter is set to true.
Callbacks at Sender’s End:
initFileUpload
– Notification to the sender when the file upload process is initiated.fileUploaded
– Notification to the sender when the file has been uploaded.fileUploadFailed
– Notification to the sender when the file upload process fails.
Callbacks at Receiver’s End:
fileUploadStarted
– Notification to the intended receiver when a file is being uploaded.fileAvailable
– Notification to the intended receiver when a file is ready to download.
Enx.sendFiles(isBroadcast,clientIdList) initFileUpload:event=>{ // To sender - File upload process started } fileUploaded:event=>{ // To sender - File upload is complete } fileUploadFailed:event=>{ // To sender - File upload has failed } fileUploadStarted:event=>{ // To intended receiver - A new file upload started } fileAvailable:event=>{ // To intended receiver - A file is available for download }
Download Shared File
The process of downloading shared file(s) comprises two steps:
- Know file(s) available for download.
- Initiate download on the available file(s).
Know files available for download
The Enx.getAvailableFiles()
method returns a JSON Object with all the files available for download.
Class: Enx
Method: Enx.getAvailableFiles()
Callback: fileAvailable
– The intended receiver is notified when a file is available for download.
Enx.getAvailableFiles() fileAvailable:event=>{ // To intended receiver - A file is available for download }
Initiate File Download
The Enx.downloadFile()
method is used to initiate the file download using the file information received above.
Class: Enx
Method: Enx.downloadFile(fileInfo,isAutoSave)
Parameters:
fileInfo
– File JSON Object available for download.isAutoSave
– Boolean. Set it to true to save the file automatically in which case you receive the saved file’s path. When set to false, you receive Base64 encoded RAW data to handle the file saving process manually.
Callbacks at Receiver’s End:
fileDownloaded
– Notification sent when the file has been downloaded with or without auto-saving.fileDownloadFailed
– Notification sent when download fails.
Enx.downloadFile(fileInfo,isAutoSave) fileDownloaded:event=>{ // To receiver - File has been downloaded } fileDownloadFailed:event=>{ // To receiver - File download has failed }
Cancel File Upload
The Enx.cancelUpload()
method allows you to cancel an ongoing file upload job initiated by you.
Class: Enx
Method: Enx.cancelUpload(upJobId)
Parameter:
upJobId
– Numeric. The Id of the file upload job.
Callback: fileUploadCancelled
– Acknowledgment to the user when the file upload is cancelled.
Enx.cancelUpload(upJobId) fileUploadCancelled:event=>{ // Acknowledgment to the user when the file upload is cancelled. }
The Enx.cancelAllUploads()
method allows you to cancel all ongoing file uploads initiated by you.
Method: Enx.cancelAllUploads()
– No Parameter required.
Callback: fileUploadCancelled
– Acknowledgment to the user when the file upload is cancelled.
Enx.cancelAllUploads() fileUploadCancelled:event=>{ // Acknowledgment to the user when the file upload is cancelled. }
Error Codes / Exceptions:
Code | Description |
---|---|
5089 | Storage Access denied. |
5090 | Failed to save file. |
5091 | File-Sharing not available in this context. |
5092 | Too many files to upload. Max 1 file allowed per request. |
1185 | File size exceeds the max allowed size. |
1182 | Failed to upload file. |
5098 | Unable to cancel file upload after file upload complete. |
5099 | Failed to cancel upload as invalid Upload ID passed as a parameter. |
5100 | Failed to upload a possibly corrupt file. |
5102 | Cancel upload not available without Web View. Non-Contextual Method Call. |
Cancel File Download
The Enx.cancelDownload()
allows you to cancel the ongoing file download job taking place at your endpoint.
Class: Enx
Method: Enx.cancelDownload(JobId)
Parameter: upJobId
– Numeric. The Id of the file download job.
Callback: fileDownloadCancelled
– Acknowledgment to the user when the file download is cancelled.
Enx.cancelDownload(JobId) fileDownloadCancelled:event=>{ // Acknowledgment to the user when the file download is cancelled. }
The Enx.cancelAllDownloads()
method allows you to cancel all ongoing file downloads taking place at your endpoint.
Method: Enx.cancelAllDownloads()
– No Parameter required.
Callback: fileDownloadCancelled
– Acknowledgment to the user when the file download is cancelled.
Enx.cancelAllDownloads() fileDownloadCancelled:event=>{ // Acknowledgment to the user when the file download is cancelled. }
Error Codes / Exceptions:
Code | Description |
---|---|
5089 | Storage Access denied. |
5090 | Failed to save file. |
1183 | Failed to download file. |
1181 | File Download not available. Non-contextual Method Call. |
5101 | File already downloaded. |