• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Node.js SDK)
  4. Initialization
  5. ObsClient Initialization

ObsClient Initialization

API Description

ObsClient functions as the Node.js client for accessing OBS. It offers callers a series of APIs for interaction with OBS. These APIs are used for managing and operating resources, such as buckets and objects, stored in OBS.

Method Definition

1. Constructor form: ObsClient(parameter)
2. Factory method form: ObsClient.factory(parameter)

Parameter Description

Field

Type

Optional or Mandatory

Description

access_key_id

String

Mandatory

AK

secret_access_key

String

Mandatory

SK

is_secure

Boolean

Optional

Whether to use HTTPS to connect OBS. The default value is true.

server

String

Mandatory

Endpoint for accessing OBS

port

Number

Optional

Port number. The default value is 80 when HTTP is used or 443 when HTTPS is used.

max_retry_count

Number

Optional

Maximum number of retries when an HTTP/HTTPS connection is abnormal. The default value is 3.

timeout

Number

Optional

Timeout period (in seconds) of an HTTP/HTTPS request. The default value is 60.

ssl_verify

Boolean

or

String

Optional

Whether to verify the server certificate. Possible values are:

  • Path to the server-side root certificate file in .pem format
  • false: The server-side certificates will not be verified.

The default value is false.

long_conn_param

Number

Optional

Long connection mode (in seconds) If the value is equal to or larger than 0, the long connection mode is enabled and this value is used as the initial delay of the TCP Keep-Alive packets.

By default, this parameter is left blank, which indicates that long connection mode is disabled.

Sample Code

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

// Create an ObsClient instance.
var obsClient = new ObsClient({
access_key_id: '*** Provide your Access Key ***', // Configure the AK.
secret_access_key: '*** Provide your Secret Key ***', // Configure the SK.
is_secure : true,// Use HTTPS.
       server : 'yourdomainname', // Configure the endpoint.
port : 443, // Configure the port number.
       max_retry_count : 1,
       timeout : 20,
       ssl_verify : false,
       long_conn_param : 0
});