{"id":4766,"date":"2021-12-07T17:39:35","date_gmt":"2021-12-07T09:39:35","guid":{"rendered":"https:\/\/www.enablex.io\/developer\/?page_id=4766"},"modified":"2025-02-23T12:55:15","modified_gmt":"2025-02-23T04:55:15","slug":"file-sharing","status":"publish","type":"page","link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/video-api\/client-api\/cordova-toolkit\/file-sharing\/","title":{"rendered":"File Sharing: Cordova\/Ionic SDK &#8211; Video API"},"content":{"rendered":"\n<p>The Platform File Share API allows users of a RTC session to send and receive file(s) to\/from each other. Using the available APIs, you can initiate file transfer to share, cancel a file transfer, get notified about a shared file and receive\/download a shared file.<\/p>\n\n\n\n<h4>Table of Contents<\/h4>\n\n\n\n<ul><li><a href=\"#upload-file\">Upload file to share<\/a><\/li><li><a href=\"#cancel-upload\">Cancel a file upload<\/a><\/li><li><a href=\"#cancel-uploads\">Cancel all files upload<\/a><\/li><li><a href=\"#available-files-download\">Know files available for download<\/a><\/li><li><a href=\"#start-download\">Initiate file download<\/a><\/li><li><a href=\"#cancel-download\">Cancel file download<\/a><\/li><li><a href=\"#cancel-all-download\">Cancel downloading all files<\/a><\/li><\/ul>\n\n\n\n<a name=\"upload-file\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Upload File to Share<\/h3>\n\n\n\n<p>The file sharing process starts with a user initiating a file transfer to Video Server. To initiate a file transfer use <code>window.EnxRtc.sendFiles()<\/code> method. <\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>sendFiles( isBroadcast, recipientIDs)<\/code><\/p>\n\n\n\n<p><strong>Parameters<\/strong>:<\/p>\n\n\n\n<ul><li><code>@param {boolean} isBroadcast<\/code> \u2013 This is to share file among all participants in the Session. If you need to target the file share to a specific user,  then set it to false.<\/li><li><code>@param {Array} recipientIDs<\/code> \u2013 Array of Client IDs. This is to share the file among specified Clients only. If broadcast is set to true, <code>recipientIDs<\/code> is ignored.<\/li><\/ul>\n\n\n\n<p><strong>Event Listeners at Sender End:<\/strong>  <\/p>\n\n\n\n<ul><li><code>onInitFileUpload<\/code> &#8211; To notify the sender that the file upload process is initiated<\/li><li><code>OnFileUploaded<\/code> &#8211; To notify the sender that the file has been uploaded<\/li><li><code>OnFileUploadFailed<\/code> &#8211; To notify the sender that the file upload process has failed<\/li><\/ul>\n\n\n\n<p><strong>Event Listeners at Receiver End:<\/strong>  <\/p>\n\n\n\n<ul><li><code>OnFileUploadStarted<\/code> &#8211; To notify the intended receiver that a file is being uploaded<\/li><li><code>OnFileAvailable<\/code> &#8211; To notify the intended received that a file is ready to download<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">window.EnxRtc. sendFiles ( broadcast, array);\n\/\/ Add Event Listeners\n\/\/ To intended receiver - A new file upload started\nwindow.EnxRtc.addEventListner(\"onFileUploadStarted\", function\n(data)\n{\nconsole.log(JSON.stringify(data.data));\n});\n\/\/ To intended receiver \u2013 A file is avilable for download\nwindow.EnxRtc.addEventListner(\"onFileAvailable\", function\n(data)\n{\nconsole.log(JSON.stringify(data.data));\n});\n\/\/ To intended receiver \u2013 File upload process has initialized.\nwindow.EnxRtc.addEventListner(\"onInitFileUpload\", function\n(data)\n{\nconsole.log(JSON.stringify(data.data));\n});\n\/\/ To intended receiver \u2013 File upload is complete.\nwindow.EnxRtc.addEventListner(\"onFileUploaded\", function\n(data)\n{\nconsole.log(JSON.stringify(data.data));\n});\n\/\/ To intended receiver \u2013 File upload has failed.\nwindow.EnxRtc.addEventListner(\"onFileUploadFailed\", function\nconsole.log(JSON.stringify(data.data));\n});<\/pre>\n\n\n\n<p><strong>Error Codes:<\/strong> Upload process may encounter error. <\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Error Code<\/strong><\/td><td><strong>Error Description<\/strong><\/td><\/tr><tr><td>5089<\/td><td>Storage Access denied<\/td><\/tr><tr><td>5091<\/td><td> File-Sharing not available in this context <\/td><\/tr><tr><td>1185<\/td><td>Too large file. Max allowed Size: NNNN<\/td><\/tr><tr><td>1182<\/td><td>Failed to upload file<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<a name=\"cancel-upload\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Cancel a File Upload<\/h3>\n\n\n\n<p>Sender of a file may like to cancel an ongoing file upload. To do so use <code>cancelUpload()<\/code> method. <\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>cancelUpload(jobId)<\/code><\/p>\n\n\n\n<p><strong>Parameters<\/strong>: <code> @param {Number} jobId <\/code>&#8211; ID of the Job to be canceled<\/p>\n\n\n\n<p><strong>Event Listeners: <\/strong> <code>onFileUploadCancelled<\/code> \u2013 It notifies when the file upload has been canceled successfully<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ To cancel single uploading file\nwindow.EnxRtc.cancelUpload(jobId);\n\n\/\/ Add Event Listeners\n\/\/ To intended receiver \u2013 File uploading is canceled.\nwindow.EnxRtc.addEventListner(\" onFileUploadCancelled \", function\n(data)\n{\nconsole.log(JSON.stringify(data.data));\n});<\/pre>\n\n\n\n<a name=\"cancel-uploads\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Cancel all Files Upload<\/h3>\n\n\n\n<p>The Sender of multiple files may like to cancel an ongoing files upload. To do so use <code>cancelAllUploads()<\/code> method. <\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>cancelAllUploads()<\/code> &#8211; No parameters required<\/p>\n\n\n\n<p><strong>Event Listeners: <\/strong> <code>onFileUploadCancelled<\/code> \u2013 It notifies when the file upload has been canceled successfully<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ To cancel all uploading file\nwindow.EnxRtc.cancelAllUploads();\n\n\/\/ Add Event Listeners\n\/\/ To intended receiver \u2013 File uploading is cancelled.\nwindow.EnxRtc.addEventListner(\" onFileUploadCancelled \", function\n(data)\n{\nconsole.log(JSON.stringify(data.data));\n});<\/pre>\n\n\n\n<a name=\"download-file\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Download a Shared File<\/h3>\n\n\n\n<p>Intended Recipients need to download each file shared with them individually. Therefore, recipients need to know the information about the available files to download to initiate a download process. <\/p>\n\n\n\n<a name=\"available-files-download\"><\/a>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4>Know Files to Download<\/h4>\n\n\n\n<p><strong>Room Lookup: <\/strong>To know what all files are available for download, you may call  <code>window.EnxRtc.getAvailableFiles()<\/code> method. It returns list of File data.<\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>getAvailableFiles( successCallback, errorCallback )<\/code><\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul><li><code>@param {CallableFunction} successCallback<\/code><\/li><li><code>@param {CallableFunction} errorCallback<\/code><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">window.EnxRtc.getAvailableFiles(function (data) {\nconsole.log('Excelsior success! ' + JSON.stringify(data.data));\n}, function (err) {\nconsole.log('Uh oh\u2026 error' + JSON.stringify(err));\n});<\/pre>\n\n\n\n<p><strong>When New File is available:<\/strong> The receiving endpoint is notified as and when a file is made available for download using Event Listener <code>onFileAvailable<\/code>  <\/p>\n\n\n\n<a name=\"start-download\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4>Initiate File Download <\/h4>\n\n\n\n<p>As you know about the file(s) to download, you need to initiate download individually using <code>window.EnxRtc.downloadFile()<\/code> method.<\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>downloadFile( fileInfo, isAutoSave )<\/code><\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul><li><code>@param {JSON} fileInfo<\/code> \u2013 Map of the file to be downloaded.<\/li><li><code>@param {boolean} isAutoSave<\/code> \u2013 Whether to save the file automatically. If not to be saved automatically, you would receive Base64 encoded RAW data to handle file saving processes manually. If auto-saving is on, you would receive the saved file path.<\/li><\/ul>\n\n\n\n<p><strong>Event Listeners at Receiver End:<\/strong><\/p>\n\n\n\n<ul><li><code>onInitFileDownload<\/code> &#8211; To notify that file download process has been initiated<\/li><li><code>onFileDownloaded<\/code> &#8211; To notify file has been downloaded with either Base64 Raw data to be saved (When auto-saving is false) or saved file path.<\/li><li><code>OnFileDownloadFailed<\/code> &#8211; To notify download failure<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">window.EnxRtc.downloadFile(JSON, isAutoSave);\n\/\/ Add Event Listeners\n\/\/ To intended receiver \u2013 File download process has initialized.\nwindow.EnxRtc.addEventListner(\" onInitFileDownload \", function\nconsole.log(JSON.stringify(data.data));\n});\n(data)\n{\/\/ To receiver - File download has failed\nwindow.EnxRtc.addEventListner(\"onFileDownloadFailed\", function\n(data)\n{\nconsole.log(JSON.stringify(data.data));\n});\n\/\/ To intended receiver \u2013 File has been downloaded.\nwindow.EnxRtc.addEventListner(\"onFileDownloaded\", function\n(data)\n{\nconsole.log(JSON.stringify(data.data));\n});<\/pre>\n\n\n\n<p><strong>Error Codes:<\/strong> Download process may encounter error that shall send notification with JSON object containing one of the following error code:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Error Code<\/strong><\/td><td><strong>Error Description<\/strong><\/td><\/tr><tr><td>5089<\/td><td>Storage Access denied<\/td><\/tr><tr><td>5090<\/td><td>Failed to save file<\/td><\/tr><tr><td>1183<\/td><td>Failed to download file<\/td><\/tr><tr><td>1181<\/td><td>File Download not available in this context<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<a name=\"cancel-download\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Cancel Downloading a File<\/h3>\n\n\n\n<p>The receiver of a file may like to cancel an ongoing download of a file by using <code>window.EnxRtc.cancelDownload()<\/code> method. <\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>cancelDownload (jobId)<\/code><\/p>\n\n\n\n<p><strong>Parameters<\/strong>:  <code>@param {Number} jobId<\/code>  &#8211; Job ID which is to be canceled.<\/p>\n\n\n\n<p><strong>Event Listeners: <\/strong> <code>onFileDownloadCancelled<\/code> \u2013  Notifies when the file download is canceled.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ To cancel single downloading file\nwindow.EnxRtc.cancelDownload(jobId);\n\n\/\/ Add Event Listeners\n\/\/ To intended receiver \u2013 File downloading is cancelled.\nwindow.EnxRtc.addEventListner(\"onFileDownloadCancelled\", function\n(data)\n{\nconsole.log(JSON.stringify(data.data));\n});<\/pre>\n\n\n\n<a name=\"cancel-all-download\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Cancel Downloading of all Files<\/h3>\n\n\n\n<p>The receiver of files may like to cancel the ongoing download of all files by using <code>window.EnxRtc.cancelAllDownloads()<\/code> method. <\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>cancelAllDownloads()<\/code><\/p>\n\n\n\n<p><strong>Event Listeners: <\/strong> <code>onFileDownloadCancelled<\/code> \u2013 Notifies when the file download is canceled.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ To cancel all downloading file\nwindow.EnxRtc.cancelAllDownloads();\n\n\/\/ Add Event Listeners\n\/\/ To intended receiver \u2013 File downloading is cancelled.\nwindow.EnxRtc.addEventListner(\"onFileDownloadCancelled\", function\n(data)\n{\nconsole.log(JSON.stringify(data.data));\n});<\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<p>\u2190 <a href=\"..\/chat\/\">Send Message<\/a><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column\">\n<p class=\"has-text-align-center\"><a href=\"..\/\">Index<\/a><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column\">\n<p class=\"has-text-align-right\"><a href=\"..\/custom-signalling\/\"><\/a><a href=\"..\/custom-signalling\/\">Custom Signalling<\/a> \u2192<a href=\"\/developer\/how-to-use\/\"><\/a><\/p>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Platform File Share API allows users of a RTC session to send and receive file(s) to\/from each other. Using the available APIs, you can initiate file transfer to share, cancel a file transfer, get notified about a shared file and receive\/download a shared file. Table of Contents Upload file to share Cancel a file upload Cancel all files upload Know files available for download Initiate file download Cancel file&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3719,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ub_ctt_via":""},"featured_image_src":null,"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"featured":false,"featured-large":false},"uagb_author_info":{"display_name":"vcxdevwpadmin","author_link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/author\/vcxdevwpadmin\/"},"uagb_comment_info":0,"uagb_excerpt":"The Platform File Share API allows users of a RTC session to send and receive file(s) to\/from each other. Using the available APIs, you can initiate file transfer to share, cancel a file transfer, get notified about a shared file and receive\/download a shared file. Table of Contents Upload file to share Cancel a file&hellip;","_links":{"self":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4766"}],"collection":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/comments?post=4766"}],"version-history":[{"count":0,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4766\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/3719"}],"wp:attachment":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/media?parent=4766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}