• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Java SDK)
  4. CORS
  5. Viewing CORS Rules

Viewing CORS Rules

You can call ObsClient.getBucketCors to view CORS rules of a bucket. Sample code is as follows:

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);


BucketCors cors = obsClient.getBucketCors("bucketname");
for(BucketCorsRule rule : cors.getRules()){
    System.out.println("\t" + rule.getId());
    System.out.println("\t" + rule.getMaxAgeSecond());
    System.out.println("\t" + rule.getAllowedHeader());
    System.out.println("\t" + rule.getAllowedOrigin());
    System.out.println("\t" + rule.getAllowedMethod());
    System.out.println("\t" + rule.getExposeHeader());
}

// Close obsClient. 
obsClient.close();