Creating an Instance of ObsClient
If you have any questions during development, post them on the Issues page of GitHub. For details about parameters and usage of each API, see the API Reference
ObsClient functions as the Node.js client for accessing OBS. It offers callers a series of APIs for interaction with OBS and is used for managing and operating resources, such as buckets and objects, stored in OBS. To use OBS Node.js SDK to send a request to OBS, you need to initialize an instance of ObsClient and modify parameters related to initial configurations of the instance based on actual needs.
By Using the Constructor
- Sample code for creating an ObsClient instance using permanent access keys (AK/SK):
// Import the OBS library. // Use npm to install the client. var ObsClient = require('esdk-obs-nodejs'); // Use the source code to install the client. // var ObsClient = require('./lib/obs'); // Create an obsClient instance by using the constructor. var obsClient = new ObsClient({ access_key_id: '*** Provide your Access Key ***', secret_access_key: '*** Provide your Secret Key ***', server : 'https://your-endpoint', }); // Use the instance to access OBS. // Close ObsClient. obsClient.close(); - Sample code for creating an ObsClient instance using temporary access keys (AK/SK and security token):
// Import the OBS library. // Use npm to install the client. var ObsClient = require('esdk-obs-nodejs'); // Use the source code to install the client. // var ObsClient = require('./lib/obs'); // Create an ObsClient instance by using the constructor. var obsClient = new ObsClient({ access_key_id: '*** Provide your Access Key ***', secret_access_key: '*** Provide your Secret Key ***', security_token: '*** Provide your Security Token ***', server : 'https://your-endpoint' }); // Use the instance to access OBS. // Close ObsClient instance. obsClient.close();
By Using the Factory Method
- Sample code for creating an ObsClient instance using permanent access keys (AK/SK):
// Import the OBS library. // Use npm to install the client. var ObsClient = require('esdk-obs-nodejs'); // Use the source code to install the client. // var ObsClient = require('./lib/obs'); // Initialize an ObsClient instance 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 : 'https://your-endpoint' }); // Use the instance to access OBS. // Close ObsClient instance. obsClient.close(); - Sample code for creating an ObsClient instance using temporary access keys (AK/SK and security token):
// Import the OBS library. // Use npm to install the client. var ObsClient = require('esdk-obs-nodejs'); // Use the source code to install the client. // var ObsClient = require('./lib/obs'); // Initialize an ObsClient instance 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 ***', security_token: '*** Provide your Security Token ***', server : 'https://your-endpoint' }); // Use the instance to access OBS. // Close ObsClient instance. obsClient.close();
- 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.
Last Article: Configuring the AK and SK
Next Article: Configuring an Instance of ObsClient
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.