Amazon web services HTTP 400错误请求-aws s3 putObjectRetention
在执行put请求时,尝试将保留设置为s3对象时,我遇到以下错误 捕获到AmazonServiceException:您提供的XML不是 格式正确或未根据我们发布的架构进行验证(服务: S3,状态代码:400,http状态=400,aws代码=MalformedXML) 我已经在s3存储桶中启用了对象锁定,并且我正在尝试从aws s3 java sdk以符合性模式向s3对象添加保留。下面是我正在使用的示例代码段Amazon web services HTTP 400错误请求-aws s3 putObjectRetention,amazon-web-services,amazon-s3,sdk,put,retention,Amazon Web Services,Amazon S3,Sdk,Put,Retention,在执行put请求时,尝试将保留设置为s3对象时,我遇到以下错误 捕获到AmazonServiceException:您提供的XML不是 格式正确或未根据我们发布的架构进行验证(服务: S3,状态代码:400,http状态=400,aws代码=MalformedXML) 我已经在s3存储桶中启用了对象锁定,并且我正在尝试从aws s3 java sdk以符合性模式向s3对象添加保留。下面是我正在使用的示例代码段 try { ObjectLockRetention l
try {
ObjectLockRetention lockRetention = ObjectLockRetention.builder()
.retainUntilDate(retention)
.build();
PutObjectRetentionRequest retentionRequest = PutObjectRetentionRequest.builder()
.bucket(bucket)
.key(id)
.retention(lockRetention)
.build();
if(ObjectLockRetentionMode.fromValue(retentionMode) == ObjectLockRetentionMode.COMPLIANCE){
lockRetention.toBuilder().mode(ObjectLockRetentionMode.COMPLIANCE);
retentionRequest.toBuilder().bypassGovernanceRetention(true);
}
else if(ObjectLockRetentionMode.fromValue(retentionMode) == ObjectLockRetentionMode.GOVERNANCE){
lockRetention.toBuilder().mode(ObjectLockRetentionMode.GOVERNANCE);
}
else{
LOGGER.warn("Not a valid retention mode!! Hence setting it to default mode : COMPLIANCE");
lockRetention.toBuilder().mode(ObjectLockRetentionMode.COMPLIANCE);
retentionRequest.toBuilder().bypassGovernanceRetention(true);
}
s3Client.putObjectRetention(retentionRequest);
} catch (AwsServiceException ase) {
ase.printStackTrace();
}
有什么我遗漏的吗?提前谢谢