{"id":4216,"date":"2021-11-11T18:01:50","date_gmt":"2021-11-11T10:01:50","guid":{"rendered":"https:\/\/www.enablex.io\/developer\/?page_id=4216"},"modified":"2025-02-24T14:56:02","modified_gmt":"2025-02-24T06:56:02","slug":"file-share","status":"publish","type":"page","link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/video-api\/client-api\/android-toolkit\/file-share\/","title":{"rendered":"File Sharing: Android SDK &#8211; Video API"},"content":{"rendered":"\n<p><strong>Availability<\/strong>: <em>Android SDK  v1.5.3+ <\/em><\/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 shared file<\/a><\/li><li><a href=\"#cancel-upload\">Cancel File Upload<\/a><\/li><li><a href=\"#cancel-file-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 <code>EnxRoom.sendFiles()<\/code> method is used to initiate a file transfer to the Video Server. <\/p>\n\n\n\n<p><strong>Class:<\/strong><code> EnxRoom <\/code><\/p>\n\n\n\n<p><strong>Observer:<\/strong> <code>public void setFileShareObserver(EnxFileShareObserver-Object)<\/code><\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>public void sendFiles(FrameLayout view, boolean isBroadcast, List clientIdList)<\/code><\/p>\n\n\n\n<p><strong>Parameters<\/strong>:<\/p>\n\n\n\n<ul><li><code>view<\/code>\u2013 FrameLayout view where UI is shown to choose files to upload.<\/li><li><code>isBroadcast <\/code>\u2013 Boolean. Set it to <em>true<\/em> to share file(s) with all the participants in the Session and <em>false<\/em> to share file(s) with the intended user(s). <\/li><li><code>clientIdList<\/code> \u2013 List of Client IDs intended to receive the file(s). This parameter is not applicable if <code>isBroadcast<\/code> parameter is set to <em>true<\/em>.<\/li><\/ul>\n\n\n\n<p><strong>Callbacks at Sender&#8217;s End:<\/strong>  <\/p>\n\n\n\n<ul><li><code>onInitFileUpload <\/code>&#8211; Notification to the sender when the file upload process is initiated.<\/li><li><code>onFileUploaded <\/code>&#8211; Notification to the sender when the file has been uploaded.<\/li><li><code>onFileUploadFailed <\/code>&#8211; Notification to the sender when the file upload process fails.<\/li><\/ul>\n\n\n\n<p><strong>Callbacks at Receiver&#8217;s End:<\/strong>  <\/p>\n\n\n\n<ul><li><code>onFileUploadStarted <\/code>&#8211; Notification to the intended receiver when a file is being uploaded.<\/li><li><code>onFileAvailable <\/code>&#8211; Notification to the intended receiver when a file is ready to download.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">room.sendFiles(FrameLayoutView, true, NULL); \n\n\/\/ To intended receiver - A new file upload started \npublic void onFileUploadStarted(JSONObject jsonObject) {\n       \/\/ Handle JSON Object with file information\n}\n\n\/\/ To intended receiver - A file is available for download \npublic void onFileAvailable(JSONObject jsonObject) {\n\t\/\/ Handle JSON Object with file information\n}\n\n\/\/ To sender - File upload process started\npublic void onInitFileUpload(JSONObject jsonObject) {\n\t\/\/ Handle JSON Object with file information\n}\n\n\/\/ To sender - File upload is complete\npublic void onFileUploaded(JSONObject jsonObject) {\n\t\/\/ Handle JSON Object with file information\n}\n\n\/\/ To sender - File upload has failed\npublic void onFileUploadFailed(JSONObject jsonObject) {\n\t\/\/ Handle upload error\n}<\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\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:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4>Know files available for download<\/h4>\n\n\n\n<p>The<strong> <code>EnxRoom.getAvailableFiles()<\/code> <\/strong>method returns a JSON Object with all the files available for download.<\/p>\n\n\n\n<p><strong>Class:<\/strong> EnxRoom <\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>public JSONObject getAvailableFiles()<\/code><\/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>Callback <code>onFileAvailable<\/code>:<\/strong> The intended receiver is notified when a file is available for download.  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ To intended receiver - A file is available for download \npublic void onFileAvailable(JSONObject jsonObject) {\n\t\/\/ Handle JSON Object with file information\n}<\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\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 <code>EnxRoom.downloadFile()<\/code> method is used to initiate the file download using the file information received above. <\/p>\n\n\n\n<p><strong>Class:<\/strong> <code>EnxRoom<\/code><\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>public void downloadFile(JSONObject fileInfo, boolean isAutoSave)<\/code><\/p>\n\n\n\n<p><strong>Parameters<\/strong>:<\/p>\n\n\n\n<ul><li><code>fileInfo<\/code>\u2013 File JSON Object available for download.<\/li><li><code>isAutoSave<\/code> \u2013 Boolean. Set it to <em>true<\/em> to save the file automatically in which case you receive the saved file&#8217;s path. When set to <em>false<\/em>, you receive Base64 encoded RAW data to handle the file saving process manually. <\/li><\/ul>\n\n\n\n<p><strong>Callbacks at Receiver&#8217;s End:<\/strong><\/p>\n\n\n\n<ul><li><code>onFileDownloaded<\/code> &#8211; Notification sent when the file has been downloaded with or without auto-saving.<\/li><li><code>onFileDownloadFailed<\/code> &#8211; Notification sent when download fails.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">room.downloadFile(JSONObject, true); \n\n\/\/ To receiver - File has been downloaded\npublic void onFileDownloaded(JSONObject jsonObject) {\n       \/\/ Handle JSON Object with file information\n}\n\n\/\/ To receiver - File download has failed\npublic void onFileDownloadFailed(JSONObject jsonObject) {\n\t\/\/ Handle download error\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 <code>EnxRoom.cancelUpload()<\/code> method allows you to cancel an ongoing file upload job initiated by you.<\/p>\n\n\n\n<p><strong>Class:<\/strong> <code>EnxRoom<\/code><\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>public void&nbsp;cancelUpload(int&nbsp;upJobId)<\/code><\/p>\n\n\n\n<p><strong>Parameter:<\/strong><\/p>\n\n\n\n<p><code>upJobId<\/code> &#8211; Numeric. The Id of the file upload job. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">enxRoom.cancelUpload(jobId);<\/pre>\n\n\n\n<p>The <code>EnxRoom.cancelAllUploads()<\/code> method allows you to cancel all ongoing file uploads initiated by you.<\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>public void&nbsp;cancelAllUploads()<\/code> &#8211; No Parameter required. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">enxRoom.cancelAllUploads();<\/pre>\n\n\n\n<p><strong>Callback: <\/strong><\/p>\n\n\n\n<p><code>onFileUploadCancelled<\/code> &#8211; Acknowledgment to the user when the file upload is canceled. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public void&nbsp;onFileUploadCancelled(JSONObject jsonObject)<\/pre>\n\n\n\n<p><strong>Error Codes \/ Exceptions:<\/strong> <\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Code<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>5089<\/td><td>Storage Access denied.<\/td><\/tr><tr><td>5090<\/td><td>Failed to save file.<\/td><\/tr><tr><td>5091<\/td><td>File-Sharing not available in this context.<\/td><\/tr><tr><td>5092<\/td><td>Too many files to upload. Max 1 file allowed per request.<\/td><\/tr><tr><td>1185<\/td><td>File size exceeds the max allowed size. <\/td><\/tr><tr><td>1182<\/td><td>Failed to upload file.<\/td><\/tr><tr><td>5098<\/td><td>Unable to cancel file upload after file upload complete. <\/td><\/tr><tr><td>5099<\/td><td>Failed to cancel upload as invalid Upload ID passed as a parameter.<\/td><\/tr><tr><td>5100<\/td><td>Failed to upload a possibly corrupt file. <\/td><\/tr><tr><td>5102<\/td><td>Cancel upload not available without Web View. Non-Contextual Method Call.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<a name=\"cancel-file-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 <code>EnxRoom.cancelDownload()<\/code> 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>public void&nbsp;cancelDownload(int&nbsp;upJobId)<\/code><\/p>\n\n\n\n<p><strong>Parameter:<\/strong><\/p>\n\n\n\n<p><code>upJobId<\/code> &#8211; Numeric. The Id of the file download job.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">enxRoom.cancelDownload(jobID);<\/pre>\n\n\n\n<p>The <code>EnxRoom.cancelAllDownloads()<\/code> method allows you to cancel all ongoing file downloads taking place at your endpoint.<\/p>\n\n\n\n<p><strong>Method:<\/strong> <code>public void&nbsp;cancelAllDownloads()<\/code> &#8211; No Parameter required.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">enxRoom.cancelAllDownloads();<\/pre>\n\n\n\n<p><strong>Callback:<\/strong><\/p>\n\n\n\n<p><code>onFileDownloadCancelled<\/code> &#8211; Acknowledgment to the user when the file download is canceled.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public void&nbsp;onFileDownloadCancelled(JSONObject jsonObject);<\/pre>\n\n\n\n<p><strong>Error Codes \/ Exceptions:<\/strong> <\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Code<\/th><th>Description<\/th><\/tr><\/thead><tbody><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. Non-contextual Method Call.<\/td><\/tr><tr><td>5101<\/td><td>File already downloaded.<\/td><\/tr><\/tbody><\/table><\/figure>\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=\"..\/custom-signalling\/\"><\/a><a href=\"..\/custom-signalling\/\">Custom Signalling<\/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<a href=\"\/developer\/how-to-use\/\"><\/a><\/p>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Availability: Android SDK 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 shared file Cancel File Upload Cancel File Download Upload File to share The&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3740,"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: Android SDK 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\/4216"}],"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=4216"}],"version-history":[{"count":0,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4216\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/3740"}],"wp:attachment":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/media?parent=4216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}