• Object Storage Service

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

Creating an Instance of ObsClient

Directly use the endpoint to create an instance of ObsClient:

String endPoint = "yourdomainname";
String ak = "*** Provide your Access Key ***";
String sk = "*** Provide your Secret Key ***";
// Create an instance of ObsClient.
ObsClient obsClient = new ObsClient(ak, sk, endPoint);
 
// Use the instance to access OBS.
        
// Close obsClient.
obsClient.close();

Use configuration class ObsConfiguration to create an instance of ObsClient.

String endPoint = "yourdomainname";
String ak = "*** Provide your Access Key ***";
String sk = "*** Provide your Secret Key ***";

// Create an instance of ObsConfiguration.
ObsConfiguration config = new ObsConfiguration();
config.setEndPoint(endPoint);
config.setHttpsOnly(true);

// Create an instance of ObsClient.
ObsClient obsClient = new ObsClient(ak, sk, config);

// Use the instance to access OBS.

// Close obsClient.
obsClient.close();
NOTE:
  • The project can contain one or more instances of ObsClient.
  • ObsClient is thread-safe and can be simultaneously used by multiple threads.
  • After you call the ObsClient.close method to close an instance of ObsClient, the instance cannot be used any more.