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)

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));
}

Also See

wrtc.onFileProgress()

wrtc.saveFile()

wrtc.sendFile()