{"id":4033,"date":"2021-11-02T19:48:36","date_gmt":"2021-11-02T11:48:36","guid":{"rendered":"https:\/\/www.enablex.io\/developer\/?page_id=4033"},"modified":"2025-03-06T15:04:37","modified_gmt":"2025-03-06T07:04:37","slug":"file-share","status":"publish","type":"page","link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/video-api\/client-api\/web-toolkit\/file-share\/","title":{"rendered":"File Share: Web SDK &#8211; Video API"},"content":{"rendered":"\n<p><strong>Availability<\/strong>: Web Toolkit v1.5.3+ <\/p>\n\n\n\n<p>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.<\/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=\"#download-file\">Download File<\/a><\/li><li><a href=\"#initiate-file-download\">Initiate File Download<\/a><\/li><li><a href=\"#cancel-upload\">Cancel File Upload<\/a><\/li><li><a href=\"#cancel-download\">Cancel File Download<\/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\u00a0<code>EnxRoom.sendFiles()<\/code>\u00a0method is used to initiate a file transfer to Video Server.<\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>EnxRoom.sendFiles(files, options, callback)<\/code><\/p>\n\n\n\n<p><strong>Parameters<\/strong>:<\/p>\n\n\n\n<ul><li><code>files<\/code> &#8211; FileList. An array of File Type Objects. This object is returned by the files property of the HTML <code>&lt;input&gt;<\/code> element that lets you access the list of files selected with the <code>&lt;input type=\"file\"&gt;<\/code> element. For more details <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/FileList\">check this<\/a>. <\/li><li><code>options<\/code> &#8211; JSON Object. This to define file sharing process, scope of file transfer etc. Following keys may be used:<ul><li><code>isMobile<\/code> &#8211; <code>Boolean<\/code>. Default: <em>false<\/em>. Set to <em>true<\/em> to develop Web View based Mobile Apps.<\/li><li><code>broadcast<\/code> &#8211; <code>Boolean<\/code>. Default: <em>true<\/em>. The value <em>true<\/em> allows you to share file with all the users in the Session. Set to <em>false<\/em> to share the file with specific user(s).<\/li><li><code>clientList<\/code> &#8211; Array of Client IDs who are intended to receieve the file(s).If <code>broadcast<\/code> is set to <em>true<\/em>, <code>clientList<\/code> is ignored.<\/li><\/ul><\/li><li><code>callback<\/code> &#8211; To receive the status response of <code>sendFiles()<\/code> method.<\/li><\/ul>\n\n\n\n<p><strong>Event Listener:<\/strong>  <\/p>\n\n\n\n<p><code>fs-upload-result<\/code> &#8211; Notification to the Sender on the file upload process such as when the file upload starts, completes or fails. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var clientList = [];\n\nvar shareOptions = {\n\t\"isMobile\": false,\n\t\"broadcast\": true,\n\t\"clientList\": clientList\n};\n\n\n\nroom.sendFiles(FileList,  shareOptions, functions(resp) {\n\tif (resp.result == \"0\") { \/\/ Success JSON Example given below\n\t\t\n\t} else {\t\/\/ Error JSON Example given below\n\t\n\t}\n});\n\n\nroom.addEventListener('fs-upload-result', function (event) {\n\tvar msg = event.message;\n\tswitch (msg.messageType) {\n\t\tcase 'upload-started':\n\t\t\t\/\/ Note msg.upJobId for management\n\t\t\t\/\/ upload-started event JSON Example given below\n\t\t\tbreak;\n\t\tcase 'upload-completed':\n\t\t\t\/\/ Know msg.upJobId is completed\n\t\t\t\/\/ upload-completed event JSON Example given belowbreak;\n\t\t\tbreak;\n\t\tcase 'upload-failed':\n\t\t\t\/\/ Know msg.upJobId has failed \n\t\t\t\/\/ upload-failed event JSON Example given belowbreak;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n});<\/pre>\n\n\n\n<p><strong>Success JSON on<\/strong> <code>sendFiles()<\/code> <strong>Callback<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\tmessageType: 'upload-completed', \n\tresult: 0,\n\tdescription: 'upload completed',\n\tresponse: {\n\t\tuploadStatus: 'completed',\n\t\tupJobId: 1,\t\/\/ #ID of the File Upload Job\n\t\tuploadInfo: {\t\/\/ SDK May provide additional information \n\t\t\tupJobId: 1,\n\t\t\tname: 'xyz.txt',\n\t\t\tsize: 100,\t\/\/ in bytes\n\t\t\ttype: text,\t\/\/ type of the file\n\t\t}\t \n\t}\n}<\/pre>\n\n\n\n<p><strong>Error JSON on<\/strong> <code>sendFiles()<\/code> <strong>Callback<\/strong>: <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\t\"result\": 1185,\t\t\/\/ A non zero error code\n\t\"error\": \"file upload failed \", \/\/ error\n\t\"desc\": \"file upload failed because file list is empty\"  \n}<\/pre>\n\n\n\n<p><strong>Event<\/strong> <code>fs-upload-result<\/code> &#8211;  <code>upload-started<\/code> <strong>status<\/strong> <strong>JSON<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\tmessageType: \"upload-started\",  \n\tresult: 0, \n\tdescription: \"upload started\",  \n\tresponse: {\n\t\tuploadStatus: \"started\",\n\t\tupJobId: 1,\n\t\tuploadInfo: {\n\t\t\tupJobId: 1\n\t\t\tname: \"ks (9).txt\"\n\t\t\tsize: 168\n\t\t\ttype: \"text\/plain\"\n\t\t}\n\t}\n}<\/pre>\n\n\n\n<p><strong>Event<\/strong> <code>fs-upload-result<\/code> &#8211; <code>upload-completed<\/code> <strong>status JSON<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\tmessageType: \"upload-completed\",  \n\tresult: 0, \n\tdescription: \"upload completed\",  \n\tresponse: {\n\t\tuploadStatus: \"completed\",\n\t\tupJobId: 1,\n\t\tuploadInfo: {\n\t\t\tupJobId: 1\n\t\t\tname: \"ks (9).txt\"\n\t\t\tsize: 168\n\t\t\ttype: \"text\/plain\"\n\t\t}\n\t}\n}<\/pre>\n\n\n\n<p><strong>Event<\/strong> <code>fs-upload-result<\/code> &#8211; <code>upload-failed<\/code> <strong>status JSON<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\tmessageType: \"upload-failed\",  \n\tresult: 1185, \n\tdescription: \"upload failed\",  \n\tresponse: {\n\t\tuploadStatus: \"failed\",\n\t\tupJobId: 1,\n\t\tuploadInfo: {\n\t\t\tupJobId: 1\n\t\t\tname: \"ks (9).txt\"\n\t\t}\n\t}\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 shared File<\/h3>\n\n\n\n<p>The process of downloading shared file(s) comprises two steps:<\/p>\n\n\n\n<ul><li>Know file(s) available for download.<\/li><li>Initiate download on the available file(s).<\/li><\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4>Know files available for download<\/h4>\n\n\n\n<p><strong>Room Lookup: <\/strong> Get the files available for download using <code>roomObject.availableFiles<\/code>, an array of JSON objects carrying file information.  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">let myFiles = room.availableFiles;\n\n\/\/ myFile contains array of File Information\n[\n\t{\n\t\tname: \"DP1.pdf\",  \n\t\tsize: 191002,\n\t\tindex: 0 \/\/ ID or File Reference\n\t} \n]<\/pre>\n\n\n\n<p><strong>When a New File is available:<\/strong> The intended receiver is notified via the event <code>fs-download-result<\/code> with <code>event.message.messageType='download-available'<\/code>, when a file is available for download.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">room.addEventListener('fs-download-result', function (event) {\n\tvar msg = event.message;\n\tswitch (msg.messageType) {\n\t\tcase 'download-available':\n\t\t\t\/\/ Look for JSON Object for file infomration\n\t\t\tbreak;\n\t\t \n\t}\n\n});<\/pre>\n\n\n\n<a name=\"initiate-file-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>The&nbsp;<code>EnxRoom.<code>recvFiles<\/code>()<\/code>&nbsp;method is used to initiate the file download using the file information received above.<\/p>\n\n\n\n<p><strong>Class:<\/strong> EnxRoom<\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>EnxRoom.recvFiles(index, options, callback)<\/code> <\/p>\n\n\n\n<p><strong>Parameters<\/strong>:<\/p>\n\n\n\n<ul><li><code>index<\/code>&#8211; ID of the file to be downloaded.<\/li><li><code>options <\/code>&#8211; JSON Object to define file download process. The JSON keys are given below:<ul><li><code>isMobile<\/code> &#8211; <code>Boolean<\/code>. Default: <em>false<\/em>. Set to <em>true<\/em> to develop Web View based Mobile Apps.<\/li><\/ul><\/li><li><code>callback<\/code> &#8211; To receive the status response of the method.<\/li><\/ul>\n\n\n\n<p><strong>Event Listener:<\/strong>  <\/p>\n\n\n\n<p><code>fs-download-result<\/code> &#8211; Notification to the Receiver on the file download process such as when the file download starts, completes or fails. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">let myFiles = room.availableFiles;\n\nroom.recvFiles(myFiles[0].index, {}, function(resp){\n\tif (resp.result == \"0\") { \/\/ Success JSON Example given below\n\t\t\n\t} else {\t\/\/ Error JSON Example given below\n\t\n\t}\t\n});\n\n\nroom.addEventListener('fs-download-result', function (event) {\n\tvar msg = event.message;\n\tswitch (msg.messageType) {\n\t\tcase 'download-started':\n\t\t\t\/\/ Note msg.jobId for cancellation\n\t\t\t\/\/ download-started event JSON Example given below\n\t\t\tbreak;\n\t\tcase 'download-completed':\n\t\t\t\/\/ Know msg.jobId is completed\n\t\t\t\/\/ download-completed event JSON Example given belowbreak;\n\t\t\tbreak;\n\t\tcase 'download-failed':\n\t\t\t\/\/ Know msg.jobId has failed \n\t\t\t\/\/ download-failed event JSON Example given belowbreak;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n});<\/pre>\n\n\n\n<p> <strong>Success JSON on<\/strong> <code>recvFiles()<\/code> <strong>Callback<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\tmessageType: 'download-success',\n\tresult: 0, \/\/ Succes\n\tdescription: 'download-success',\n\tresponse: {\t\/\/ SDK May provide additional information \n\t\tdownloadStatus: 'success',\n\t\tname: xyz.txt,\n\t\ttype: text,\n\t\tsize: 100 \/\/ in bytes\n\t}  \n}<\/pre>\n\n\n\n<p><strong>Error JSON on<\/strong> <code>recvFiles()<\/code> <strong>Callback<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\t\"result\": 1180, \/\/ A Non-Zero error code\n\t\"error\": \"room is disconected\",\n\t\"desc\": \"File sharing is not allowed on disconnected rooms\"\n}\n<\/pre>\n\n\n\n<p><strong>Event<\/strong> <code>fs-download-result<\/code> &#8211; <code>download-started<\/code> <strong>status JSON<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\tmessageType: \"download-started\",  \n\tresult: 0, \/\/ Success \n\tdescription: \"download-started\", \n\tresponse: {\n\t\tdownloadStatus: \"started\",\n\t\tjobId: \"0\", \/\/ Job ID for downloads in progress\n\t\tdownloadInfo: {\t\/\/ SDK May provide additional information \n\t\t\tname: \"ks (4).txt\", \n\t\t\tsize: 168, \/\/ In bytes\n\t\t\tindex: 0,\n\t\t}  \n\t}\n}<\/pre>\n\n\n\n<p><strong>Event<\/strong> <code>fs-download-result<\/code> &#8211;  <code>download-completed<\/code> <strong>status JSON<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\tmessageType: \"download-completed\",  \n\tresult: 0, \/\/ Success \n\tdescription: \"download-completed\", \n\tresponse: {\n\t\tdownloadStatus: \"completed\",\n\t\tjobId: \"0\", \/\/ Job ID for completed download\n\t\tdownloadInfo: {\t\/\/ SDK May provide additional information \n\t\t\tname: \"ks (4).txt\", \n\t\t\tsize: 168, \/\/ In bytes\n\t\t\tindex: 0\n\t\t}  \n\t}\n}<\/pre>\n\n\n\n<p><strong>Event<\/strong> <code>fs-download-result<\/code> &#8211; <code>download-failed<\/code> <strong>status JSON<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\tmessageType: \"download-failed\",  \n\tresult: 0, \/\/ failed \n\tdescription: \"download-failed\", \n\tresponse: {\n\t\tdownloadStatus: \"failed\",\n\t\tjobId: \"0\", \/\/ Job ID for completed download\n\t\tdownloadInfo: {\t\/\/ SDK May provide additional information \n\t\t\tname: \"ks (4).txt\", \n\t\t\tsize: 168, \/\/ In bytes\n\t\t\tindex: 0\n\t\t}  \n\t}\n}<\/pre>\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 File Upload<\/h3>\n\n\n\n<p>The&nbsp;<code>EnxRoom.cancelUploads()<\/code>&nbsp;method allows you to cancel an ongoing file upload job initiated by you.<\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>EnxRoom.cancelUploads(id, cancelAll, callback)<\/code><\/p>\n\n\n\n<p><strong>Parameters<\/strong>:<\/p>\n\n\n\n<ul><li><code>id<\/code>\u2013 <code>Numeric<\/code>. upJobId of the file being uploaded. This Id is received via <code>sendFiles()<\/code> method.<\/li><li><code>cancelAll<\/code>\u2013 <code>Boolean<\/code>. Default: <em>false<\/em>. Set to <em>true<\/em> to cancel all file uploads. <\/li><li><code>callback<\/code> \u2013 To receive status of cancelation request.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">room.cancelUploads(id, false, function(resp) {\n\t\/\/ Handle response here\n});<\/pre>\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 File Download<\/h3>\n\n\n\n<p>The&nbsp;<code>EnxRoom.cancelDownloads()<\/code>&nbsp;allows you to cancel the ongoing file download job taking place at your endpoint. <\/p>\n\n\n\n<p><strong>Class:<\/strong> EnxRoom<\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>EnxRoom.cancelDownloads(id, cancelAll, callback)<\/code><\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul><li><code>id<\/code>\u2013 <code>Numeric<\/code>. <code>jobId<\/code> of the file being downloaded. This jobId is received via <code>recvFiles()<\/code> method.<\/li><li><code>cancelAll<\/code>\u2013 <code>Boolean<\/code>. Default: <em>false<\/em>. Set to <em>true<\/em> to cancel all files being downloaded. <\/li><li><code>callback<\/code> \u2013 To receive status of the cancelation request. <\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">room.cancelDownloads(id, false, function(resp) {\n\t\/\/ Handle response here\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=\"..\/screen-share\/\">Screen Share<\/a>  \u2192 <\/p>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Availability: Web Toolkit v1.5.3+ 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 Download File Initiate File Download Cancel File Upload Cancel File Download Upload File to&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3724,"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":"Availability: Web Toolkit v1.5.3+ 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&hellip;","_links":{"self":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4033"}],"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=4033"}],"version-history":[{"count":0,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4033\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/3724"}],"wp:attachment":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/media?parent=4033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}