我们使用 ceph 和 radosgw 通过s3 java api访问我们的故事。当我们尝试设置CORS规则时,java api返回带有错误代码MalformedXML的AmazonS3Exception(打印为“ null”)(调试显示我的 CORSRule 对象的所有字段都没有一个字段,为空)。
我在这里完全遵循s3指南:https://docs.amazonaws.cn/en_us/AmazonS3/latest/dev/ManageCorsUsingJava.html
这是我的实现方式
private void setCORS() {
List<CORSRule> corsRules = new ArrayList<>();
corsRules.add(new CORSRule().withAllowedOrigins(Arrays.asList("*rocket_CHAT_DOMAIN*")). //
withAllowedMethods(Arrays.asList(AllowedMethods.PUT,AllowedMethods.POST,AllowedMethods.GET,AllowedMethods.HEAD)). //
withMaxAgeSeconds(3000). //
withAllowedHeaders(Arrays.asList("*")));
s3Client.setBucketCrossOriginconfiguration(cephBucket,new BucketCrossOriginconfiguration(corsRules));
}
奇怪的是,当我尝试创建CORS规则时,Windows工具 S3浏览器返回的结果完全相同。
有人通过 ceph 中的 radosgw 设置CORS规则的经验吗?最佳使用S3库?