use of com.aliyun.oss.model.SetBucketCORSRequest.CORSRule in project aliyun-oss-java-sdk by aliyun.
the class BucketOperationsSample method doBucketCORSOperations.
private static void doBucketCORSOperations() {
SetBucketCORSRequest request = new SetBucketCORSRequest(bucketName);
CORSRule r0 = new CORSRule();
r0.addAllowdOrigin("http://www.a.com");
r0.addAllowdOrigin("http://www.b.com");
r0.addAllowedMethod("GET");
r0.addAllowedHeader("Authorization");
r0.addExposeHeader("x-oss-test");
r0.addExposeHeader("x-oss-test1");
r0.setMaxAgeSeconds(100);
request.addCorsRule(r0);
System.out.println("Setting bucket CORS\n");
client.setBucketCORS(request);
System.out.println("Getting bucket CORS:");
List<CORSRule> rules = client.getBucketCORSRules(bucketName);
r0 = rules.get(0);
System.out.println("\tAllowedOrigins " + r0.getAllowedOrigins());
System.out.println("\tAllowedMethods " + r0.getAllowedMethods());
System.out.println("\tAllowedHeaders " + r0.getAllowedHeaders());
System.out.println("\tExposeHeaders " + r0.getExposeHeaders());
System.out.println("\tMaxAgeSeconds " + r0.getMaxAgeSeconds());
System.out.println();
System.out.println("Deleting bucket CORS\n");
client.deleteBucketCORSRules(bucketName);
}
Aggregations