华为 obs相关
public class HwObsController {
@Value("${hw-obs.ak}")
private String hwObsAk;
@Value("${hw-obs.sk}")
private String hwObsSk;
@Value("${hw-obs.endPoint}")
private String hwObsEndpoint;
@Value("${hw-obs.bucketName}")
private String hwObsBucketName;
@RequestMapping(path = "/getBucketList")
public void getBucketList(){
try {
logger.info("ak:{}, sk:{}, endpoint:{}, bucketName:{}", hwObsAk, hwObsSk, hwObsEndpoint, hwObsBucketName);
// 创建ObsClient实例
ObsClient obsClient = new ObsClient(hwObsAk, hwObsSk, hwObsEndpoint);
ListBucketsRequest request = new ListBucketsRequest();
request.setQueryLocation(true);
List<ObsBucket> buckets = obsClient.listBuckets(request);
for(ObsBucket bucket : buckets){
logger.info("bucketName:{}, creationDate:{}, location:{}", bucket.getBucketName(), bucket.getCreationDate(), bucket.getLocation());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}