MozNFCPeer.sendFile()

The sendFile() method of the MozNFCPeer interface sends a file — over a non-NFC data channel — to another device.

Note: sendFile() currently uses Bluetooth for data transport.

Syntax

var req = nfcPeer.sendFile(flieblob);

Example

var nfcdom = window.navigator.mozNfc;
nfcdom.onpeerready = function(event) {
  var nfcPeer = nfcdom.getNFCPeer(event.detail);
  var blob = ... // construct a 'blob' that is of type 'file'.
  // This 'blob' will be passed onto / handover to Bluetooth interface for the actual file transfer. (Wifi handover is not yet supported)
  var req = nfcPeer.sendFile(blob);
  req.onsuccess = function(e) {
    console.log("Successfully sent file");
  };
  req.onerror = function(e) {
    console.log("Send file failed!");
  };
};

Parameters

The Blob file reference to be transferred.

Returns

A DOMRequest object.

Errors

Error("Unable to create NFCPeer object, Reason:  Bad SessionToken")

Specifications

The NFC implementation in Gecko follows the NFC Forum specifications.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support

No support

No support No support No support No support
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support No support No support 2.0 moz [1] No support No support No support

[1] Available in privileged apps as of Firefox OS 2.2; certified-only before that.

See also

Document Tags and Contributors

 Contributors to this page: chrisdavidmills, fscholz, lgarner
 Last updated by: chrisdavidmills,