Conditional requests
Conditional Requests in the S3 API allow performing operations only when certain conditions are met using headers. You can use them 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 various scenarios.
Headers
PutObject operations
For examples of uploading objects with conditions, see the Upload object section of the AWS CLI guide.
CopyObject and UploadPartCopy operations
For examples of copying objects with conditions, see the Copy object section of the AWS CLI guide.
DeleteObject operations
For examples of deleting objects with conditions, see the Delete object section of the AWS CLI guide.
CompleteMultipartUpload operations
Error descriptions
Use case examples
- protection against update conflicts — the object will be updated only if it has not changed since the last request (the
If-Matchheader); - data synchronization — the object will be downloaded only if it was modified after the specified time (the
If-Modified-Sinceheader); - read optimization — the object will be retrieved only if it does not match the local version (the
If-None-Matchheader); - overwrite protection — the object will not be written to the key if another object with that key already exists (the
If-None-Matchheader).