====== onFileReceived() ====== wrtc.onFileReceived() is an event function called once a complete file has been received. You can use this event to save the received file to a local file. ===== Arguments ===== wrtc.onFileReceived(fileName, fileBase64, fromAddress) * fileName - string containing name of received file * fileBase64 - string containing contents of received file encoded in [[https://en.wikipedia.org/wiki/Base64|Base64]] format * fromAddress - string containing address file was sent from Depending on how the file was sent fileBase64 may or may not start with a data header specifying [[https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types|mime type]], eg data:image/jpeg;base64 ===== Return value ===== Ignored. ===== Example ===== wrtc.onFileReceived = function(fileName, fileBase64, fromAddress) { if (fileBase64.match(/^data:/)) wrtc.saveFile(fileName, fileBase64); else wrtc.saveFile(fileName, window.atob(fileBase64)); } ===== Also See ===== [[ixnx:wrtc:js:api:wrtc:onfileprogress|wrtc.onFileProgress()]] [[ixnx:wrtc:js:api:wrtc:savefile|wrtc.saveFile()]] [[ixnx:wrtc:js:api:wrtc:sendfile|wrtc.sendFile()]]