• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Node.js SDK)
  4. Initialization
  5. Creating an Instance of ObsClient

Creating an Instance of ObsClient

By Using the Constructor

// Import the OBS library.
var ObsClient = require('./lib/obs');

// Create an instance of ObsClient by using the constructor.
var obsClient = new ObsClient({
       access_key_id: '*** Provide your Access Key ***',
       secret_access_key: '*** Provide your Secret Key ***',
       server : 'yourdomainname'
});

// Use the instance to access OBS.

// Close obsClient.
obsClient.close();

By Using the Factory Method

// Import the OBS library.
var ObsClient = require('./lib/obs');

// Create an instance of ObsClient by using the factory method.
var obsClient = new ObsClient();
obsClient.factory({
       access_key_id: '*** Provide your Access Key ***',
       secret_access_key: '*** Provide your Secret Key ***',
       server : 'yourdomainname'
});

// Use the instance to access OBS.

// Close obsClient.
obsClient.close();
NOTE:
  • The project can contain one or more instances of ObsClient.
  • After you call the ObsClient.close method to close an instance of ObsClient, the instance cannot be used any more.