Table of Contents
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 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 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));
}