Conditional requests
Conditional requests in the S3 API allow you to perform operations only when certain conditions are met using headers. They can be used to:
- perform read and write requests with a preliminary check of object state;
- manage object updates and uploads based on their current state or metadata;
- comply with common usage scenarios according to S3 standards;
- protect data against accidental overwriting;
- optimize traffic costs.
Conditional requests can be used for different scenarios.
Headers
PutObject operations
Examples of uploading objects with conditions can be found in the Upload object subsection of the AWS CLI manual.
CopyObject and UploadPartCopy operations
Examples of copying objects with conditions can be found in the Copy object subsection of the AWS CLI manual.
DeleteObject operations
Examples of deleting objects with conditions can be found in the Delete object subsection of the AWS CLI manual.
CompleteMultipartUpload operations
Error descriptions
Use case examples
- update conflict protection — the object will be updated only if it has not changed since the last access (
If-Matchheader); - data synchronization — the object will be uploaded only if it was modified after the specified time (
If-Modified-Sinceheader); - read optimization — the object will be retrieved only if it does not match the local version (
If-None-Matchheader); - overwrite protection — the object will not be written to the key if there is already another object with that same key (
If-None-Matchheader).