Object Lock API Examples
This section lists s3curl examples of Object Lock APIs.
NOTE: Put and Get Object Lock APIs can be used with and without
versionId parameter. If no
versionId parameter is used, then the action applies to the latest version.
Operation
API request examples
Create lock-enabled bucket
s3curl.pl --id=ecsflex --createBucket -- http://${s3ip}/my-bucket -H "x-amz-bucket-object-lock-enabled: true"
Enable object lock on existing bucket
s3curl.pl --id=ecsflex -- http://${s3ip}/my-bucket?enable-object-lock -X PUT
Get bucket default lock configuration
s3curl.pl --id=ecsflex -- http://${s3ip}/my-bucket?object-lock
Put bucket default lock configuration
s3curl.pl --id=ecsflex -- http://${s3ip}/my-bucket?object-lock -X PUT \
-d "<ObjectLockConfiguration><ObjectLockEnabled>Enabled</ObjectLockEnabled>
<Rule><DefaultRetention><Mode>GOVERNANCE</Mode><Days>1</Days></DefaultRetention></Rule></ObjectLockConfiguration>"
Get legal hold
s3curl.pl --id=ecsflex -- http://${s3ip}/my-bucket/obj?legal-hold
Put legal hold on create
s3curl.pl --id=ecsflex --put=/root/100b.file -- http://${s3ip}/my-bucket/obj -H "x-amz-object-lock-legal-hold: ON"
Put legal hold on existing object
s3curl.pl --id=ecsflex -- http://${s3ip}/my-bucket/obj?legal-hold -X PUT -d "<LegalHold><Status>OFF</Status></LegalHold>"
Get retention
s3curl.pl --id=ecsflex -- http://${s3ip}/my-bucket/obj?retention
Put retention on create
s3curl.pl --id=ecsflex --put=/root/100b.file -- http://${s3ip}/my-bucket/obj -H "x-amz-object-lock-mode: GOVERNANCE" -H "x-amz-object-lock-retain-until-date: 2030-01-01T00:00:00.000Z"
Put retention on existing object
s3curl.pl --id=ecsflex -- http://${s3ip}/my-bucket/obj?retention -X PUT -d "<Retention><Mode>GOVERNANCE</Mode><RetainUntilDate>2030-01-01T00:00:00.000Z</RetainUntilDate></Retention>"
Put retention on existing object (with bypass)
s3curl.pl --id=ecsflex -- http://${s3ip}/my-bucket/obj?retention -X PUT -d "<Retention><Mode>GOVERNANCE</Mode><RetainUntilDate>2030-01-01T00:00:00.000Z</RetainUntilDate></Retention>" -H "x-amz-bypass-governance-retention: true"