Replies: 1 comment 1 reply
-
@Fais-007 apologies for the lack of replies. Looking at the API Reference I couldn't find other API that would return Object Lock properties, so yes calling |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using this code to check if bucket has object lock enabled or not:
GetObjectLockConfigurationRequest getObjectLockConfigurationRequest = GetObjectLockConfigurationRequest .builder().bucket(bucketName).build(); GetObjectLockConfigurationResponse getObjectLockConfigurationResponse = s3Client .getObjectLockConfiguration(getObjectLockConfigurationRequest); return getObjectLockConfigurationResponse.objectLockConfiguration().objectLockEnabledAsString() .equals("Enabled");
It is working fine for bucket with object lock enabled but throwing exception if object lock is disabled.
software.amazon.awssdk.services.s3.model.S3Exception: Object Lock configuration does not exist for this bucket (Service: S3, Status Code: 404, Request ID: 519BPB5AAMVCEB14, Extended Request ID: 6LK0fOzC7RzVQJK/e7tuW5qVWWg1zWTor9KRf3AOQARA/zrcp+OFGit3Czno2pKzP99l5ko1L7Q=)
Is this the correct way to check for this or is there any other way to do it.
Beta Was this translation helpful? Give feedback.
All reactions