B2G OS

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

Supported in Firefox OS 2.0 for certified-apps.
Available in privileged apps as of Firefox OS 2.2.

See also

Document Tags and Contributors

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