Guides

JavaScript API

Connector provides a rich set of APIs so you can control how it works to suit your web application needs.

initConnector

This API is the starting point for Connector. Use this to initialize the Connector. It uses sensible default options which can be overridden.

📘

If Connector is already initialized, calling initConnector() again will re-initialize it with the new parameters.

initConnector with default options

Initialize Connector with default options. serviceToken is a mandatory parameter.

FileSpin.initConnector({
  serviceToken: "INSERT_YOUR_SERVICE_TOKEN",
});

initConnector with callback on ready

FileSpin.initConnector(settings, function() {}) API can be used to safely take actions only when the Connector is ready. You can pass a callback function as the second argument which will be called when the Connector is ready.

Below code initializes the Connector, and using the callback function when the Connector is ready, it displays an alert and shows the Connector.

FileSpin.initConnector(
  {
    serviceToken: "INSERT_YOUR_SERVICE_TOKEN",
  },
  function () {
    //this function is called when Connector is initialized and ready
    alert("Connector ready!");
  }
);

showConnector

Use this API to programmatically show the Connector dialog.

FileSpin.showConnector();

hideConnector

Use this API to programmatically hide the Connector dialog.

FileSpin.hideConnector();

resetConnector

This API resets the Connector by clearing current search and any file selections. It does not change the initialization parameters.

FileSpin.resetConnector();

updateConnectorSettings

Convenience method to update Connector with the new settings without reloading it.

FileSpin.updateConnectorSettings(connectorSettings);

connectorSettings are the same as for initConnector API as defined in Connector configuration above.

Here is a sample connectorSettings:-

FileSpin.updateConnectorSettings({
  serviceToken: "INSERT_YOUR_SERVICE_TOKEN",
  lang: "en",
  maxSelection: 30,
  hideOnMaxSelect: false,
  dialogTitle: {
    en: "FileSpin Connector",
  },
});